$ 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.
In the root of your project, run the following in the command line:
npm i handlebars-helper-minify --save-dev
All options from js-beautify are available in this helper, as well as a few custom options that were specially created for this helper. The helper comes with some sensible defaults (in the humble opinion of the helper creator), but it's easy to customize them if you need to. Here are are two (convenient) ways to set options:
{{#minify opts.obj}}.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:
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:
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.
{
collapseBooleanAttributes: false,
collapseWhitespace: true,
removeAttributeQuotes: false,
removeCDATASectionsFromCDATA: false,
removeComments: false,
removeCommentsFromCDATA: false,
removeEmptyAttributes: false,
removeEmptyElements: false,
removeOptionalTags: false,
removeRedundantAttributes: false,
useShortDoctype: false
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- code comment -->
<h1>My Blog</h1>
<h2>Post of the day</h2>
<!-- scripts -->
<a href="#">Read more...</a>
</body>
</html>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title></title></head><body><!-- code comment --><h1>My Blog</h1><h2>Post of the day</h2><!-- scripts --><a href="#">Read more...</a></body></html>
Please see the Contributing to Assemble guide for information on contributing to this project.
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license
This file was generated on March 10, 2014.