Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Avoid HTML in JavaScript [closed]

I have a lot of elements that are created on the fly from data received on the server, as JSON. To create these elements a lot of HTML is going inside my JavaScript code. Is there any solution to this problem? The JavaScript code is polluted and writing HTML tags becomes harder and less maintainable.

like image 325
user3704920 Avatar asked Jun 12 '14 23:06

user3704920


1 Answers

Templating tools such as handlebars, mustache and dust.js were designed to solve this very problem.

like image 184
sahbeewah Avatar answered Sep 30 '22 05:09

sahbeewah