开发者

client-side templating

Its been a while since i am working with the AJAX and getting templates from server-side hence creating huge traffic.

Fetching same HTML on single page with only开发者_JS百科 different data, sometimes i feel guilty that i can do better than that.

Then an idea clicked in my mind and i researched on client-side templating.

Only thing i found good enough (i thought so since i did not practiced it yet), was jQote2 http://aefxx.com/jquery-plugins/jqote2/.

I just want suggestion from gurus that is it worth? Is there another good alternative?


Here's my favorite:

http://ejohn.org/blog/javascript-micro-templating/

It looks like this:

<script type="text/html" id="user_tmpl">
  <% for ( var i = 0; i < users.length; i++ ) { %>
    <li><a href="<%=users[i].url%>"><%=users[i].name%></a></li>
  <% } %>
</script>

Its author is John Resig, creator of jQuery. Hope this helps. Cheers


I've not used jQote but I have used jQuery Templates which I believe is the official templating solution although someone might correct me on that. I've only had the chance to use it in a few home projects but so far I really like it especially for rendering out static content like in my news ticker example.

You can take a look at it here jQuery Templates

Dave Ward has some nice blog posts and also Stephen Walther

I've done a few jsFiddle's that show some basic syntax

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜