Im trying to print a json object using underscore but it is not displaying. If I use the default template for underscore it works but since I am using JSP, I cannot use the default template for underscore. I'm trying to change it so that {{ }} works as my template instead.
I have the following templateSettings :
<script type="text/javascript">
_.templateSettings = {
evaluate: /\{\{#(.+?)\}\}/g,
interpolate: /\{\{([^#].*?)\}\}/g
};
</script>
My json file looks like
{
"input": {
"birthday": "Birthday"
},..
} My template file is:
<script type = "text/template" id ="name">
Name2: {{ name2 }} // prints [object Object]<br />
Name2.input: {{ name2.input }} //doesnt print <br />
Name2.input.birthday: {{ name2.input.birthday }} //doesnt print
</script>
Is there something wrong with the regex?