Automattic / juice

Juice inlines CSS stylesheets into your HTML source.
MIT License
3.12k stars 221 forks source link

Code blocks not fully ignored when in `style` tag #405

Open itamar-getloam opened 2 years ago

itamar-getloam commented 2 years ago

Hi, I'm using juice to pack an HTML file which uses Handlebars, and I found what seems to be a bug. Here's the reproduction.

To sum it up, if we process the following HTML:

<style>
    .somediv {
        color: blue;
    }

</style>

<!-- First example: Condition is outside of tag value and is ignored successfully -->
<div class="somediv" {{#if @first}} style="border-top: 1px solid #D7DFDF;" {{/if}}></div>

<!-- Second example: Condition is inside the tags value and the second part is dropped ( {{/if}} ) -->
<div class="somediv" style="{{#if @first}} border-top: 1px solid #D7DFDF; {{/if}}"></div>

You can see that the second example is missing its closing {{/if}} I tried playing around and adding several, more specific, options to codeBlocks, but to no avail.