vapor / leaf

🍃 An expressive, performant, and extensible templating language built for Swift.
https://docs.vapor.codes/4.0/leaf/getting-started
MIT License
434 stars 81 forks source link

反义符导致 比较难受的bug #234

Open h4acda opened 4 hours ago

h4acda commented 4 hours ago

Describe the issue

反义符 导致 无法渲染 变量

Vapor version

4.4.0

Operating system and version

macOS 15.0

Swift version

6.0

Steps to reproduce

在leaf文件中 输入:Hello\#(name) 应该输出Hello\World 可是如果有\就会导致无法识别name 这是个非常严重的BUG了 目的就是输出Hello\World 请正面解决 不要以自定义标签等代替方案

Outcome

No response

Additional notes

No response

h4acda commented 4 hours ago

实际示例 test.leaf 文件内容为 <?php namespace app\#(app)\controller#(app); 渲染数据为 req.view.render("test", renderData(app: "admin")) struct renderData: Content, Encodable { let app: String } 渲染后为<?php namespace app\#(app)\controlleradmin; 第一个#(app)无法渲染 因该为<?php namespace app\admin\controlleradmin; 由于返回为代码 所以希望解决一下这个问题

h4acda commented 3 hours ago

if(menu.controller_name.contains("/")):

use app\controller\Admin;

endif 请问如何判断menu.controller_name是否包含"/"