I have:
<script id="foo" type="text/x-jquery-tmpl">
<p>${100 * parseInt(x)}</p>
</script>
When I do:
$('#foo').tmpl({'x':5}) // or '5'
I get a TypeError (undefined method).
But if I remove the parseInt or if I move the 100 to come after the parseInt, everything works!
I've been searching and everything I find says th开发者_如何学JAVAat ${}
should be able to handle arbitrary expressions, but there seems to be some syntax magic/intolerance going on here.
Any explanations?
You need to do like this:
<p>100 * parseInt(${x})</p>
精彩评论