minimize icon indicating copy to clipboard operation
minimize copied to clipboard

Allow some comments

Open adam-lynch opened this issue 10 years ago • 8 comments

See https://github.com/murphydanger/gulp-minify-html/issues/27

adam-lynch avatar Jun 17 '15 17:06 adam-lynch

Nevermind, going with gulp-htmlclean (it accepts regular expressions).

adam-lynch avatar Jun 17 '15 17:06 adam-lynch

Sure feel free to use what you want :) thats why OS is awesome. Re-opening this though as I can easily add this functionality.

Swaagie avatar Jun 18 '15 13:06 Swaagie

:+1:

What would the API look like?

adam-lynch avatar Jun 18 '15 13:06 adam-lynch

I was thinking about a plugin that would allow the comments, have to give it some thought though, don't want to just make it a configurable option, as it is highly opinionated towards Knockout (which is fine, but not for a general HTML minifier ;))

Swaagie avatar Jun 18 '15 14:06 Swaagie

Have this need as well: would it make sense to allow the ssi option to accept a regex in addition to a boolean that would then protect anything that matches? I'm using this in conjunction with underscore/lodash templates, and if I try to use the spare:true option, then something like <% if (data){ print="foo"; } %> becomes something like <% if="" (data)="" {="" print="foo";="" }="" %>

dtipson avatar Jun 18 '15 18:06 dtipson

Minimize really shouldn't be used on templates though, only the rendered output of the template should be ran through minimize. In your defence, do you render the template client side/browser as I can see a use case for that? In your example spare won't help as it only works for element attributes not variable assignments

Swaagie avatar Jun 18 '15 22:06 Swaagie

Yep, in my case of templates, there is no final rendered output: the html templates (plus language specific control code) is intended to be minified (currently using minimize via a gulp task) before being run through a template compiler. Javascript code like value == 5 gets turned into value "==" 5. Would definitely be nice to specify custom ignore delimiters, but I understand if you think that's out of scope of something intended to deal just with compliant html.

dtipson avatar Jul 08 '15 16:07 dtipson

I dont see why template code needs to be minified before parsing it though? Its just an order of task executions. Compile first, minimize after and you should be fine. The reason the JS code (in case of ejs) is mistakingly minified is because the checks look like HTML attribute assignments. Could you give an example of why the order of execution has to be minimize and then compile?

Swaagie avatar Jul 09 '15 10:07 Swaagie