Closed joebnb closed 9 years ago
i mean how to use template to make a count fill in elements
You can use #index, or #getIndex():
{{for people}}
{{:#index}}
{{/for}}
See the sample using {{:#index + 1}}
on http://www.jsviews.com/#assigntag
can i use javascript in script template? i think it can solve many problems. because i need make a determinant and count them,this is my smarty code: ignore these Chinese - 0-
You can set any template to allow code - (tmpl.allowCode=true) then use {{* //any code }} within the template. But it is better to encapsulate your code in helper functions, and call it in that way:
http://www.jsviews.com/#helpers
For allowCode, see for example:
See also
@joebnb: Did allowCode work for you?
yes,as you said its works
data: people = {"1":["0004","\u5218","XN"],"2":["0016","\u4e0","XN"],"3":[00198","\u6bdb","XN"]} template: {{for people}} var i=0 i++ {{:i}} {{/for}} but it doesn't work,my English is poor...