Skip to content

inlinecss twig tag url encoding href #42

Open

Description

@icedevelopment

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?

Activity

  1. cordoval commented on Dec 1, 2017

    @cordoval
    Member

    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.

  2. icedevelopment commented on Dec 4, 2017

    @icedevelopment
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions