leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Inline templates ? #140

Closed daslicht closed 9 years ago

daslicht commented 9 years ago

How would you handle templates for items which you render at runtime? Do you place the item template inline and just make it invisible ? Or is there a better way?

rikukissa commented 9 years ago

If you are using Browserify it'd recommend that you install either https://www.npmjs.com/package/stringify or https://www.npmjs.com/package/browserify-plain-jade and just do something like this:

var element = $(require('./myTemplate.html'));
element.render(data, directives);
$('#somewhere').prepend(element);

If I couldn't use browserify, I would probably use hidden templates in my html-files.

In conclusion I'd say that the best way of doing this is definitely with a module loader like browserify or webpack.

daslicht commented 9 years ago

Thank you for the reply !