This issue is outdated, but grunt-contrib-htmlmin and html-minifier can take new parameters.
As @mckramer already mentioned, grunt-contrib-htmlmin is on top of html-minifier , so you can add additional parameters :
customAttrAssign:<value>
Regular Expression Arrays That Support Custom Attribute Expressions
customAttrSurround:<value>
Regular Expression Arrays That Support Custom Volumetric Attributes
Decision
Grunt example (for double brackets {{ }} ):
var hbAttrWrapOpen = /\{\{(#|\^)[^}]+\}\}/; var hbAttrWrapClose = /\{\{\/[^}]+\}\}/; var hbAttrWrapPair = [hbAttrWrapOpen, hbAttrWrapClose]; htmlmin: { blabla: { options: { ... customAttrSurround: [hbAttrWrapPair] }, files: [ ... ] } }
These are the only limitations as per the documentation :
...
Note that these expressions are used to parse individual attribute + value pairs, so a single Handlebars expression cannot have multiple attributes. For example, the following markup will not be recognized:
<img src="logo.svg" {{#if logo_title}}alt="{{logo_title}}" title="{{logo_title}}"{{/if}} />
Instead, each attribute should be individually wrapped:
<img src="logo.svg" {{#if logo_title}}alt="{{logo_title}}"{{/if}} {{#if logo_title}}title="{{logo_title}}"{{/if}} />
To do this, you just follow your markup, and it will work without problems.
source share