Along with the many utilities it provides, the Underscore library also includes a simple, fast, and flexible templating engine. These templates are most commonly compiled to JSTs for use in the frontend of a web application.
In this recipe, we'll make use of the contrib-jst (0.6.0)
plugin to compile a template that renders a minimalistic blog.
In this example, we'll work with the basic project structure we created in the Installing Grunt on a project recipe in Chapter 1, Getting Started with Grunt. Be sure to refer to it if you are not yet familiar with its contents.
The following steps take us through creating a simple Underscore template and compiling it to a JST contained in another file.
We'll start by installing the package that contains the
contrib-jst
plugin as per the instructions provided in the Installing a plugin recipe in Chapter 1, Getting Started with Grunt.Let's create a simple Underscore template file called
blog.html...