The generation of content by combining logic and data poses a unique set of problems, and template engines are specifically designed to solve them. In this chapter, we'll mostly be focusing on generating HTML using various template engines, even though some of them are designed in such a way as to allow for the generation of pretty much any type of readable file format.
Even though many of the more feature-rich web application frameworks available in the JavaScript community provide for the on-demand compilation, rendering and caching of templates, doing so using Grunt provides for the flexibility required in building a highly optimized and specialized solution. Templates can be rendered directly to HTML or compiled to JSTs that can be used directly without any extra processing. The products of these templates can also be packaged to be made available in pretty much any environment you might want to use them in.
At the time of writing, there are many great templating engines available...