Reputation: 1781
All we like simple, structured code that is easy to comply with. We try to bring a difference between appearance and logics. In PHP, for instance, we can use a template mechanism, i.e. create an html-formatted file with php tags that uses some predefined variables that get ready for use through a logic resposible script.
Is there some analog for JavaScript?
What methods do you use to create dynamic content of certain type? (For example list items, complex forms that can be repeated several times)
Upvotes: 0
Views: 308
Reputation: 326
There are many js template engin as below. Choose as you want. Handlebars is my suggestion.
Upvotes: 2
Reputation: 37673
Underscore.js has simple templating mechanism as well. (And I think it must be in every javascript developer's toolbox).
jQuery's is more sophisticated, though - and probably more useful (Update: but now is deprecated).
Upvotes: 1
Reputation: 47776
Try looking into jQuery Templates. It is one of the many solutions available.
Upvotes: 0
Reputation: 400
I've used things like js-template for client side templates. For server side, whatever template mechanism was present in the system at hand could usually be applied to plain text javascript files.
Upvotes: 1