I’m trying to use backbone.js with underscore.js templates in an asp.net web forms application and coming across a problem with the templates.
<script id='Template' type='text/template'>
<span class="description <%=Description%>"></span>
</script>
This page won’t work in asp.net webforms because webforms uses the same <% and %> notation as underscores templates, resulting in an error at runtime
Compiler Error Message: CS0103: The name ‘Description’ does not exist
in the current context
Is there a way to get this working in asp.net web forms, or will I have to use a different templating library?
You can override underscore.js template settings. Take a look at _.templateSettings and the documentation (http://documentcloud.github.com/underscore/#template). You can define your own regex for nesting data.
e.g.