In an underscore template, is there any other way to access an attribute besides by its name? I’ve got one called “2a” and I cannot reference it directly, due to its first character being a number. For example, this doesn’t work:
<input type="checkbox" name="6a" <%= 6a ? "checked" : "" %>>
Thanks!
You have a few options other than renaming the offending attribute.
Underscore’s
_.templatehas avariableoption:So you could do this:
and this:
Demo: http://jsfiddle.net/ambiguous/hBhfu/
You could also wrap it manually when you call the template function:
You’d use the same template as above in this case.
Demo: http://jsfiddle.net/ambiguous/8AZKw/