Recently i had gone through Scottgu's Blog where he had jotted of Jquery Templates i would like to know when and where to use these templates and where i开发者_如何学Got should not be used. It would be very great of you, if you come forward with some simple examples.
Like any templating system, jQuery templates give you the option to specify your content more declaratively than programmatically. Here are two examples of doing the same thing:
<p>Hello {{name}}! Are you having a good {{day_or_evening}}?</p>
as opposed to:
str = "<p>Hello " + name + "! Are you having a good " + day_or_evening + "?</p>";
In these cases where you're building up bits of HTML which have a few parameters that change then obviously it's much more readable with a template. You need to find the balance yourself for where it's more readable to construct the string programmatically than through a template.
精彩评论