using Handlebars and grunt-contrib-htmlmin inside of inline-CSS or Html elements
(I'm thinking maybe @alexlamsl can help me out with this one..)
Please see my Stackoverflow post with details about my problem: http://stackoverflow.com/questions/36363547/grunt-htmlmin-clean-css-breaking-my-handlebars-code-within-style-style-tags/36598847
In sum, I have Handlebars code that is getting jankified when run through htmlmin. One example looks like this:
<style type="text/css">
{{#each list}}
.aClassWithBgImage{{@index}}{background-image:url({{images.thumbnailBoxImage}})}
{{/each}}
</style>
and htmlmin is completely wrecking that (see SO for more details). Another tricky one is this:
<input type="radio" name="field_name" value="99" autocomplete="off" {{checked}}>
...which I WAS able to fix using the RegEx mentioned in my SO post, (i.e. ignoreCustomFragments: [/{{[\s\S]*?}}/]) but that same RegEx was not able to fix the CSS problem code above, since it left whitespaces in various places, like before and after ".aClassWithBgImage". So, after minification, instead of looking like
{{#each list}}.aClassWithBgImage{{@index}}{background-image:url({{images.thumbnailBoxImage}})}{{/each}}
...my code actually looks like:
{{#each list}} .aClassWithBgImage {{@index}}{background-image:url({{images.thumbnailBoxImage}})}{{/each}}
Sorry, I am somewhat new to this, but any help would be appreciated... Obviously there are workarounds I know I could (and already have) implement, but I feel like I'm missing something.
https://github.com/jakubpawlowicz/clean-css is what we use in minifyCSS, and they don't support things like Handlebars to begin with IIRC.
The primary aim of ignoreCustomFragments is to workaround otherwise invalid input and not give up with an error; optimal output being secondary objective. If you want the perfect minfied output, you should feed minify() with the result after Handlebars' rendering.
Closing. Please reopen if there are any further issues.
Sorry I went AWOL. That is fine -- there are plenty of other ways I can accomplish what I'm doing anyway. I appreciate the help