Closed nddery closed 8 years ago
Just re-read the README and saw that
Minimize does not correctly parse inline PHP or raw template files. Simply because this is not valid HTML and never will be either. The output of the templaters should be parsed and minified.
I imagine Handlebars template are considered raw template file ? Is there an option to not parse the HTML (or some of it) and simply minimize it instead ?
I'm looking into writing (or finding) a plugin that could skip over Handlebars expressions and helpers.
Yup handlebars are also template files. I'm not sure if a plugin would be helpful here. The problem lies in the fact that htmlparser2 transforms the HTML to a tree. And it usually just parses the assignments inside template directives as html attributes. There is little that can be done about this. Your welcome to try writing a plugin, but I highly doubt you'll receive normal input in the iterator. At that point the the template directives are scrambled already. The better option is to first parse the template and then process the outputted HTML with minimize.
I was just looking at the output of htmlparser2 and was unfortunately going to the same conclusion.. Unfortunately, we are processing the template on the browser so this won't be possible for us (at least for now, apparently support for that is on it's way). However, I'm not sure I see the benefit of minifying on the client, as you've already sent the extra bytes you'd gain from minification ?
Solved by plugin
I'm having an issue minimizing an Handlebars template.
get's minimized as:
It seems like minimize is trying to minimize my Handlebars template into xHTML compliant markup. If I put my Handlebars helper directly in an element attribute (between the quotes), it will get minimized just fine, see example below.
Source HTML
Minimized HTML (formatted for readability):
It is easy to fix the example just above, however, I am not sure how to deal with the
selected
attribute. Is there a way to indicate to minimize not to parse some HTML ?Thanks!