20
rated 0 times
[
23]
[
3]
/ answers: 1 / hits: 164345
/ 13 Years ago, mon, august 29, 2011, 12:00:00
I'm using the underscore.js templating function and have done a template like this:
<script type=text/template id=gridItem>
<div class=griditem <%= gridType %> <%= gridSize %>>
<img src=<%= image %> />
<div class=content>
<span class=subheading><%= categoryName %></span>
<% if (date) { %><span class=date><%= date %></span><% } %>
<h2><%= title %></h2>
</div>
</div>
</script>
As you can see I have an if statement in there because all of my models won't have the date parameter. However this way of doing it gives me an error date is not defined
. So, how can I do if statements within a template?
More From » templates