Use Consolidate.js for templating of files in your Grunt projects. Very useful for preprocessing (build specific file content, such as: LiveReload snippet, non minified assets), and keeping things dry in HTML, JS etc.
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-consolidate --save-dev
In your project's Gruntfile, add a section named
consolidate to the data object passed into
The name of the engine used to template your files, you should have the engine in your node_modules, so make sure it is installed before defining the engine, uses consolidate.js underhood.
Check Consolidate.js for more information.
Passed through to the actual template engine, for example, if you use Dust.js as template engine for Consolidate, than this is passed raw as argument to render the template.
In this example, we are using Dust.js. As you can see, the local option is an object that is passed in to all templates, you could define your helpers, view logic here.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
AUTHOR: Mike Vercoelen