Skip to content

Instantly share code, notes, and snippets.

@jshaw
Created July 19, 2012 13:55
Show Gist options
  • Save jshaw/3144083 to your computer and use it in GitHub Desktop.
Save jshaw/3144083 to your computer and use it in GitHub Desktop.
Underscore.js template conditional example
// If URL is available URL link the image
// Otherwise just display the image
<% if ( instagram_link_url ) { %> <a href="<%= instagram_link_url %>" target="_blank"> <% } %>
<img src="<%= url %>" alt="<%= username %>" />
<% if ( instagram_link_url ) { %> </a> <% } %>
// Example 2 - Check if formated date
<% if (typeof(date) != "undefined") { %>
<span class="date"><%= date %></span>
<% } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment