Swaagie / minimize

Minimize HTML
MIT License
162 stars 18 forks source link

Mishandling Underscore/LoDash Template Strings #57

Closed willpracht closed 8 years ago

willpracht commented 8 years ago

Looks like minimize is interpreting Underscore template strings as HTML elements.

Example:

Original

<h1>
  <%= myTitle %>
</h1>

Minified

<h1><%= mytitle %></%=></h1>

It would be nice if it recognized these template strings and didn't attempt to either close the tag or transform the placeholder to lowercase.

Swaagie commented 8 years ago

Sorry for the late response, was on holiday the last week. It would be nice, but this cannot be done by minimize. This requires a custom domparser for htmlparser2 that understands the fact template strings are included in the HTML. I won't add support for this directly in the module, rather i'd make sure minification happens until after the template is parsed

willpracht commented 8 years ago

Hey, not a problem. I know we've all got lives outside of work (hopefully).

I ended up having to switch over to html-minifier via gulp-htmlmin (instead of gulp-minify-html) which uses minimize.

Unfortunately I have to do my minification before parsing the template. We're generating our $templateCache (Angular) from our templates, then parsing said templates full of LoDash template strings later on when the app is served. Not really the most ideal situation, admittedly. And maybe that's our real solution, to strip these template strings altogether and utilize the power of Angular expressions in all instances instead of most.

willpracht commented 8 years ago

Thanks for the reply, man. Appreciate your time :).