Better with Templates!
Using JavaScript templates, building a list could look something like:
There are a variety of libraries for making templates in JavaScript. I'll mention a few, and we'll focus on one in our examples (Handlebars):
- Handlebars, Handlebars provides the power necessary to let you build semantic templates effectively with no frustration.
- Mustache, "Logic-less" templates
- Nunjucks — A rich and powerful templating language for JavaScript.
- LiquidJS — A simple, expressive and safe template engine.