{{minify}} handlebars helper, for minification of HTML with html-minifier.
npm install handlebars-helper-minify> {{minify}} handlebars helper, for minification of HTML with html-minifier.
This helper depends on and extends js-beautify. Please visit and star that project to show your support.
``bash`
npm i handlebars-helper-minify --save-dev
* options object: pass an options object to the helper as a parameter. E.g. {{#minify opts.obj}}.
* options hash: this is an easy way to set options on the helper, and it also gives you granular control over how the helper renders content.
* Gruntfile: if you use both Grunt and Assemble, you can define options in the Assemble task options of your project's Gruntfile.
#### options hash
By design, options define here will override options defined anywhere else. This approach also provides granular control over options, allowing you to defined different options on multiple instances of the helper in the same file.
Example:
`handlebars`
{{#minify removeComments="true"}}
{{> header }}
{{/minify}}
{{#minify removeEmptyElements="true"}}
{{> body }}
{{/minify}}
{{#minify removeComments="true"}}
{{> footer }}
{{/minify}}
#### "assemble" task options
The helper can be used without Grunt or Assemble. But if you happen to use these two awesome tools you can define options for the helper in your Gruntfile in the minify sub-options for Assemble:
`javascript`
grunt.initConfig({
assemble: {
options: {
minify: {
removeAttributeQuotes: false
}
},
files: {}
}
});
Options defined in the Assemble task can be viewed as custom "global" defaults, which can be overridden by options defined in the options hash.
`js`
{
collapseBooleanAttributes: false,
collapseWhitespace: true,
removeAttributeQuotes: false,
removeCDATASectionsFromCDATA: false,
removeComments: false,
removeCommentsFromCDATA: false,
removeEmptyAttributes: false,
removeEmptyElements: false,
removeOptionalTags: false,
removeRedundantAttributes: false,
useShortDoctype: false
}
#### Before
`html
#### After
`html``My Blog
Post of the day
Read more...
Jon Schlinkert
+ twitter/jonschlinkert
+ github/jonschlinkert
+ handlebars-helpers
+ helpers: some great handlebars helpers that we decided not to include in the handlebars-helpers project, most likely because the code footprint was too big or the helper wasn't generic enough.
*
_This file was generated on March 10, 2014._