A grunt task for minifying and removing whitespace from Handlebars templates.
This plugin requires Grunt ~0.4.0
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-handlebars-min --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks("grunt-handlebars-min");
Run this task with the grunt handlebarsmin
command.
Use the grunt-handlebarsmin
task by specifying a target source and a target destination and a destination extension.
"handlebarsmin": {
dist: {
files: {
"./min/div.handlebars": "./templates/div.handlebars",
"./min/table.handlebars": "./templates/table.template"
}
}
}
"handlebarsmin": {
dist: {
src: "./templates/handlebars/*.handlebars",
dest: "./templates/min/",
expand: true,
ext: ".handlebars" // optional
}
}
The handlebars
task is a multi task, meaning that it will implicitly iterate over all of its targets if no target is specified.
Feel free to fork if you see possible improvements, or contact me directly if you want to contribute to this project (or just submit a pull request).