htmlnano
htmlnano copied to clipboard
Minify script templates
Source:
<script type="text/x-handlebars-template">
<div class="entry">
<h1>{{title}}</h1>
</div>
</script>
Minified:
<script type="text/x-handlebars-template"><div class="entry"><h1>{{title}}</h1></div></script>
+1
Instead of having a built-in template list, what about implementing the feature like this:
{
minifyHtmlTemplate: [
// [Tag Name, Attribute Name (Optional), Attribute Value (Optional)]
['script', 'type', 'text/x-handlebars-template'], // Matches script[type='text/x-handlebars-template']
['template', id, 'my-template'] // Matches template[id='my-template']
]
}
or this:
{
minifyHtmlTemplate: [
{ tag: 'script', attrs: { type: 'text/x-handlebars-template' } }, // Matches script[type='text/x-handlebars-template']
{ tag: 'script', attrs: { id: 'my-template' } }, // Matches template#my-template
}
Looks good to me!
Instead of having a built-in template list
I think it's still good if we provide some built-in template list with an option to replace it or provide additional rules.