An alternative to @stuart's solution is to use a javascript template engine, like handlebars.
As a rule of thumb, I think that as soon as you create a render
function, you should ask yourself if such a template engine would be useful. Template engines allow you to render html in a declarative way, which is often much more readable.
There is plenty of existing engines, check this stackoverflow question this stackoverflow question for more insight.
An alternative to @stuart's solution is to use a javascript template engine, like handlebars.
As a rule of thumb, I think that as soon as you create a render
function, you should ask yourself if such a template engine would be useful. Template engines allow you to render html in a declarative way, which is often much more readable.
There is plenty of existing engines, check this stackoverflow question for more insight.
An alternative to @stuart's solution is to use a javascript template engine, like handlebars.
As a rule of thumb, I think that as soon as you create a render
function, you should ask yourself if such a template engine would be useful. Template engines allow you to render html in a declarative way, which is often much more readable.
There is plenty of existing engines, check this stackoverflow question for more insight.
An alternative to @stuart's solution is to use a javascript template engine, like handlebars.
As a rule of thumb, I think that as soon as you create a render
function, you should ask yourself if such a template engine would be useful. Template engines allow you to render html in a declarative way, which is often much more readable.
There is plenty of existing engines, check this stackoverflow question for more insight.