How do i if/then in "mustache"
I use underscore.js for HTML Templating, set to use mustache syntax, like this: {{ }}
I have this code:
<% if (typeof(date) != "undefined") { %>
<span class="date"><%= date %></span>
<% } %>
How can I translate it to an underscore.js mustache-style template, using {{ }}
?
I use:
_.templateSettings = {
evaluate : /{[([sS]+?)]}/g,
interpolate : /{{([sS]+?)}}/g
};
Then instead of <%= … %>
use {{ … }}
and instead of <% … %>
use {[ … ]}
http://handlebarsjs.com/ is mustache with logic, partials, helpers & context. It can also be precompiled. A must IMHO.
{{#date}}
<span class="date">{{date}}</span>
{{/date}}
链接地址: http://www.djcxy.com/p/72072.html
上一篇: .sass文件的Netbeans 7.x语法高亮显示?
下一篇: 我如何/然后在“小胡子”