5

Why doesn't this work:

 <input type="text" name="givenName" <% if(givenName) {%> value="<%= givenName %>" <% } %>/><br/>

It throws a reference error saying givenName is not defined, which it may not be and is the reason for the conditional.

rob_hicks
  • 1,734
  • 3
  • 23
  • 35
  • 1
    The answer to this question worked for me: http://stackoverflow.com/questions/7230470/how-to-use-if-statements-in-underscore-js-templates/9321127#9321127 – jasonlcrane Apr 12 '12 at 17:45

1 Answers1

3

Rob you want to check if (locals.givenName)

 <input type="text" name="givenName" <% if(locals.givenName) {%> value="<%= givenName %>" <% } %>/><br/>
Doron Segal
  • 2,242
  • 23
  • 22