Q:

Underscore JS template If loop issue

I am trying to add an attribute (rel="tooltip") based on if condition 
<div class="symbol"><span title="<%= data%>" <% if ( data.length > 9 ) { rel="tooltip" }%>></span></div>

If I am adding an alert inside if loop it works, where as the attribute change does not work.

A:

This has nothing to do with JavaScript (or Underscore.js) at all.
<% %> are ASP tags, and rel="tooltip" is just setting a variable.  You need to have ASP echo out "tooltip" (like you did with the title).
<div class="symbol"><span title="<%= data %>" rel="<%= data.length > 9 ? "tooltip" : "" %>></span></div>

