0
mustache.js是否支持这样的表情? - >{{类型== “一”}}mustache.js是否支持这样的表情判断?
我该怎么办?
胡子:
{{#items}}
{{type == "a"}}
<li>{{name}} {{type}}</li>
{{/link}}
{{type == "b"}}
<strong>{{name}} {{type}}</strong>
{{type == "c"}}
<span>{{name}} {{type}}</span>
{{/link}}
{{/items}}
JSON:
{
"header": "Colors",
"items": [
{"name": "red", "type": "a", "url": "#Red"},
{"name": "green", "type": "b", "url": "#Green"},
{"name": "blue", "type": "c", "url": "#Blue"}
],
"empty": false
}
想输出:
<li>red a</li>
<strong>green b</strong>
<span>blue c</span>
感谢,你知道什么模板引擎的支持表达判断呢?我不明白为什么“小胡子”做出的逻辑少,不方便使用,有什么好处呢? –
至于为什么:http://stackoverflow.com/questions/3896730/whats-the-advantage-of-logic-less-template-such-as-mustache ..话虽如此,即使没有逻辑小胡子是真正强大,当你来使用它。例如,在你的json中有一个函数被Mustache中的引用调用是完全合法的。现在,如果该功能是对json中的其他数据进行处理,那么您很快就会意识到它的效果很好。 –
谢谢,根据你的说法,我在这里尝试一下:http://mustache.github.com/#demo为什么** {{name}} {{type}} **不输出任何内容? –