Swaagie / minimize

Minimize HTML
MIT License
162 stars 18 forks source link

Minifier stripping double-quotes on script tag #39

Closed VincentVToscano closed 9 years ago

VincentVToscano commented 9 years ago

I'm trying to minify all of my template files that have been precompiled. Each has a script tag surrounding the processed template. When I use gulp-minify-html on the following processed template, the script tags attributes loose their double quotes and the html is no longer valid:

Original file:

<script id="tpl_Dreamscape.handlebars" type="text/x-handlebars-template">
<div class="another" id="DreamscapeMyIDHere" >
        <div id="itemNumberSec1" tabindex="0" class="porthole One" style="background:#003344">Sec1</div>
        <div id="itemNumberSec2" tabindex="0" class="porthole Two" style="background:#FF0033">Sec2</div>
        <div id="itemNumberSec3" tabindex="0" class="porthole Three" style="background:#999999">Sec3</div>
        <div id="itemNumberSec4" tabindex="0" class="porthole Four" style="background:rgb(255,0,255)">Sec4</div>
</div>
</script>

Result:

<script id=tpl_Dreamscape.handlebars type=text/x-handlebars-template><div class="another" id="DreamscapeMyIDHere" > <div id="itemNumberSec1" tabindex="0" class="porthole One" style="background:#003344">Sec1</div> <div id="itemNumberSec2" tabindex="0" class="porthole Two" style="background:#FF0033">Sec2</div> <div id="itemNumberSec3" tabindex="0" class="porthole Three" style="background:#999999">Sec3</div> <div id="itemNumberSec4" tabindex="0" class="porthole Four" style="background:rgb(255,0,255)">Sec4</div> </div></script>

Usage:

return gulp.src( 'build/min-templates/*.handlebars' )
                .pipe(minifyHTML()).pipe(gulp.dest('build/min-templates/'));
Swaagie commented 9 years ago

This is intended, if you'd like to keep the quotes you could pass the option quotes: true which will keep arbitrary quotes. Also it's valid HTML5, it might not validate for 4.01, but that is outside the scope of this project. Closing, feel free to re-open if you think I'm missing the issue.

VincentVToscano commented 9 years ago

Thank you. Adding quotes true fixed it.

.pipe(minifyHTML({quotes: true}))