I encoded the response from the database in json, getting a json with this structure that I sent with echo from a controller with json_encode ( I work in php):
[
{column1: value, column2: value...} //row 1
{column1: value, column2: value...} //row 2
.... //row n
]
My script (my template in handlebar) is:
<script id="handlebars_deals_list" type="text/x-handlebars-template">
{{#each data}}
{{tittle}}
{{/each}}
</script>
I passed the context in this way:
var source=jQuery('#handlebars_deals_list').html();
var template = Handlebars.compile(source);
var context={data:response};//response is the json data I showed earlier
console.log(context); //Object{data="\n[{"id":"149417","biz_n......null,"index_deal":"0"}]"}
var html=template(context);
console.log(html); //empty!!?!?!?!!?!?!?!?!, why????
But I dont see any template rendered
after fighting a little with this issue I had the solution:
}