iCanHaz.js - separating templates?

905 Views Asked by At

Using ICanHaz.js is really nice - it's dead simple to create, load and render templates from javascript objects. However, in a somewhat big javascript application, the .html-file that initiates my application and contains all the ICanHaz-templates has become really crowded with template-script tags.

So how should I separate my templates to make things clear again? Are there an alternative to IcanHaz.js that applies better to larger projects?

1

There are 1 best solutions below

0
On BEST ANSWER

Most client side template engines have the same concept. You could load the templates remotely using XHR but that will add a terrible overhead of the HTTP request.

A better alternative could be creating each one in its own file, and having a server side script merge then in to your HTML page.

Finally, the last option is to add them inline in your javascript rendering functions - this will work for very small templates.