Bug Work-Around Example: jQuery Templates #118
https://github.com/jquery/jquery-tmpl/issues/118
Not a great idea to name your variables this way, but you can get to them in a template with array notation.
HTML
<div class="results"></div>
<script id="itemTemplate" type="text/x-jquery-tmpl">
{{each(i, prop) $data.Hits}}
<p>${prop["autn:summary"]}</p>
{{/each}}
</script>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type='text/javascript' src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
JavaScript
$(function() {
var data = {
Hits: [
{
"autn:summary": "test1",
"Nayas":"text"
},
{
"autn:summary": "test2",
"Nayas":"text"
},
{
"autn:summary": "test3",
"Nayas":"text"
}
]
};
$("#itemTemplate").tmpl(data).appendTo($(".results"));
});