Alex Rivera | Logout

How do i if/then in "mustache"-like underscore.js?

Asked 2012-01-24T17:16:30.190
10

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 {{ }}?

Edit
Report

1 Answer

0
{{#date}}
<span class="date">{{date}}</span>
{{/date}}
answered 2012-01-27T00:49:09.267

Your Answer