We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<%%>里可以写JS,但是有注释就出错了 双斜杠好像不行
另外请问下 <%%>里如何读取传进去的数据呢
The text was updated successfully, but these errors were encountered:
不建议使用这种语法,<%%>不支持注释的。最好使用Juicer封装的更好用的方式来写,Juicer支持 <%%>是为了兼容之前micro-tmpl的模板,新模板请使用Juicer语法。
${abc} 输出数据 {# 注释内容}
中文文档见:http://juicer.name/docs/docs_zh_cn.html
Sorry, something went wrong.
哦 看来还是有一定的限制。 毕竟封装好的方法有一定限制。
其实我要实现的是 在模板里通过传进去的data 定义 一组变量。然后在模板里输出。 比如
<% var name; if(data.sex=='man'){//问题就在这里 我没办法获得传进来的data name="张三"; }else{ name="李四" } %>
......//其他东西
我不想把判断放在tpl里面,因为如果name用的地方多,则需要写很多个if。
请问这个如果用封装好的方法有办法解决吗
可以借助 juicer 的自定义 helper 函数解决之。
比如模板这么写: ${data.sex | name}
// 定义 helper juicer.register('name', function(sex) { if(sex=='man'){ return "张三"; }else{ return "李四" } });
// 渲染,输出张三 juicer('${data.sex | name}', {data: {sex: 'man'}});
No branches or pull requests
<%%>里可以写JS,但是有注释就出错了
双斜杠好像不行
另外请问下 <%%>里如何读取传进去的数据呢
The text was updated successfully, but these errors were encountered: