htmlnano icon indicating copy to clipboard operation
htmlnano copied to clipboard

Minify script templates

Open maltsev opened this issue 8 years ago • 3 comments

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>

maltsev avatar Feb 01 '16 11:02 maltsev

+1

icai avatar Jan 12 '18 06:01 icai

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
}

SukkaW avatar Oct 10 '20 16:10 SukkaW

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.

maltsev avatar Oct 11 '20 07:10 maltsev