tijsverkoyen / CssToInlineStyles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very usefull when you're sending emails.
BSD 3-Clause "New" or "Revised" License
5.8k stars 187 forks source link

unwanted html entity conversion in HTML attributes values #163

Closed quazardous closed 8 years ago

quazardous commented 8 years ago

I'm using the inline tool to precompile Twig template.

<a href="{{ url('change_lost_password', {token: token.token}) }}" class="btn-primary">Change my password</a>

and the result is:

<a href="%7B%7B%20url('change_lost_password',%20%7Btoken:%20token.token%7D)%20%7D%7D" class="btn-primary" style="...">Change my password</a>

how can I avoid the %7B%7B%20 stuff in the href attribute ?

stof commented 8 years ago

Well, the issue is that the Twig template is not HTML markup. As such, trying to inline styles here is wrong. In your case, it breaks the Twig markup, but it could also break the inlining itself (in case you have classes added dynamically for instance, of {% if %} blocks around HTML attributes making the Twig markup invalid HTML.

You should perform the inlining on HTML markup, not on a Twig template. This means that the inlining should be done after rendering the template, not before.

quazardous commented 8 years ago

Yeah I figure it out... I'll put the inline class call after the rendering stuff....

thx for answering !