Comments (3)
不建议使用这种语法,<%%>不支持注释的。最好使用Juicer封装的更好用的方式来写,Juicer支持 <%%>是为了兼容之前micro-tmpl的模板,新模板请使用Juicer语法。
${abc} 输出数据
{# 注释内容}
中文文档见:http://juicer.name/docs/docs_zh_cn.html
from juicer.
哦 看来还是有一定的限制。
毕竟封装好的方法有一定限制。
其实我要实现的是 在模板里通过传进去的data 定义 一组变量。然后在模板里输出。
比如
<%
var name;
if(data.sex=='man'){//问题就在这里 我没办法获得传进来的data
name="张三";
}else{
name="李四"
}
%>
......//其他东西
我不想把判断放在tpl里面,因为如果name用的地方多,则需要写很多个if。
请问这个如果用封装好的方法有办法解决吗
from juicer.
可以借助 juicer 的自定义 helper 函数解决之。
比如模板这么写: ${data.sex | name}
// 定义 helper juicer.register('name', function(sex) { if(sex=='man'){ return "张三"; }else{ return "李四" } });
// 渲染,输出张三 juicer('${data.sex | name}', {data: {sex: 'man'}});
from juicer.
Related Issues (20)
- 怎么获得循环的数据的总个数 HOT 2
- 子模板不支持each循环遍历?
- 模版中自定义的数字展示形式
- 带参数的自定函数的使用说明存在错误
- 支持webpack啦,juicer-loader
- 如果在jsp中是用的话,${} 会被当做el表达式优先编译 HOT 1
- 注册函数时的参数说明不确切
- {@each array|function as item} 是否支持这样的写法 想要对需要遍历的数组在开始遍历之前做一个简单的处理
- 官方文档中的一个示例错误
- 特殊符号# 等怎么处理? HOT 1
- 判断 {@if} ... {@else if} ... {@else} ... {@/if}
- 用juicer渲染数据后 不能设置自定义属性
- 怎么获取字典的动态key的值??
- 字段名包含短横线时,无法正确解析
- 无法渲染数据,而是直接输出了源码
- 域名过期了 http://juicer.name HOT 2
- 庆祝退休
- 需要生成${,请问该怎么写? HOT 1
- 多重嵌套的if语句不支持吗
- ReDoS vulnerability in juicer.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from juicer.