Search code examples
phpjqueryajaxjquery-pluginsclient-side-templating

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 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?


Solution

  • 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