[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

HTML Templating

Michael Haufe (\"TNO\")

5/26/2015 5:53:00 PM

What is the community's personal approach for performing HTML Templating? Are you still using some library such as mustache.js? Are you using some collection of strings in your code with an associated format function, or something else entirely?
1 Answer

ram

5/26/2015 6:13:00 PM

0

"Michael Haufe (TNO)" <tno@thenewobjective.com> writes:
>What is the community's personal approach for performing HTML Templating?

It is recommanded to keep HTML out of JavaScript , so you'd
put your template into the HTML file (you can hide it there
in a comment entry or in a script entry with a custom
language-type) or retrieve it from the server (for example,
using AJAX).

Simple templates can be instantiated by just

template.replace( /VARNAME/g, WHATEVER );

. For complex templating, check out Handlebars.