gushphp / ToInlineStyleEmailBundle

A Symfony2 bundle to use the CssToInlineStyles converter by Tijs Verkoyen
MIT License
59 stars 34 forks source link

inlinecss twig tag url encoding href #42

Open icedevelopment opened 6 years ago

icedevelopment commented 6 years ago

When using the inlinecss twig tag in a template, every href value is apparently url encoded by tijsverkoyen/css-to-inline-styles.

This was mentioned here and is particularly annoying when using special templating tags provided by MailChimp for example.

Example:

{% inlinecss 'path/to/stylesheet.css %}
    To unsubscribe, click <a href="*|UNSUB|*">here</a>.
{% endinlinecss %}

will result in the following HTML:

To unsubscribe, click <a href="*%7CUNSUB%7C*">here</a>.

instead of:

To unsubscribe, click <a href="*|UNSUB|*">here</a>.

How can we avoid this behavior?

cordoval commented 6 years ago

what do you think is the reason to encode whatever is inside of the hrefs?

disregarding this, do you know if any other twig tree node parsing/rule does the same to the hrefs? or it is just this implementation?

I would say don't use it, and use the service and method calls. That is what i do.

icedevelopment commented 6 years ago

According to the issue I mentioned, this encoding is done when calling DomDocument::saveHTML() so it's not related to twig. I'm not sure there is a way to configure DomDocument to leave href values unencoded.

I think there should be a warning in the docs regarding the use of inlinecss tags.