Friday, 6 September 2013

What's wrong with my Template code?

What's wrong with my Template code?

Can anybody help me please to fix my template problem ? I am using JQuery
with Template from Blueimp/JavaScript-Template. Here is my template code..
<script type="text/x-tmpl" id="tmpl-global-result">
{% for (var i = 0; i < 5; i++) { %}
<span>result{%=i%}</span>
{% } %}
</script>
And call it from anther place as like
console.log($(tmpl("tmpl-global-result", someJSONArray)).html());
That will show only one statement result0.
So I add a <div> tag. as like ...
<script type="text/x-tmpl" id="tmpl-global-result">
<div>
{% for (var i = 0; i < 5; i++) { %}
<span>result{%=i%}</span>
{% } %}
</div>
</script>
That may return to my console result0 result1 result2 result3 result4..
Why ? Any suggestion would be appreciate. That may scratch my head.

No comments:

Post a Comment