Minimize Handlebars attributes plugin
This is experimental, use in production is not recommended.
A minimize plugin to handle Handlebars template in element attributes
Usage
Note: This plugin is not compatible with the spare
option.
var Minimize = hbattribs = minimize = spare: false plugins: hbattribs ; var html = '<div id="divID" class="my-class your-class" {{#ifCond is true}}selected{{/if}}>A div</div>'; minimize;
Why ?
Minifing HTML with minize
will give you valid HTML. But what if when you HTML
contains some Handlebars template ? What if you HTML looked like this:
{{#forEach presets}} {{this.key}} {{/forEach}}
Although this will produce valid HTML once it's parsed by Handlebars, it is not
valid HTML at the time of minifying. Here's the output from running this through
minimize
:
{{this.key}}
Notice how the Handlebars template is all split up ?
This plugin attemps to mitigate the issue by re-structuring the tree output from
htmlparser2
, which is used by minimize
. A downside is that everything will
be lowercase'd.