Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iCanHaz.js - separating templates?

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?

like image 680
Industrial Avatar asked Nov 04 '22 06:11

Industrial


1 Answers

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.

like image 54
u.k Avatar answered Nov 07 '22 23:11

u.k