Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAML links resulting in inline HTML #81

Open
alexlsalt opened this issue Mar 18, 2021 · 1 comment
Open

HAML links resulting in inline HTML #81

alexlsalt opened this issue Mar 18, 2021 · 1 comment

Comments

@alexlsalt
Copy link

Issue

When using mjml-rails in conjunction with haml, the expected haml behavior of embedding a Ruby link into a line with = resulted in inline HTML instead of a functioning link.

%mj-text
    = "Link your Twitter, Slack, and GitHub accounts today. #{link_to 'Set up integrations >', user_settings_url(@user)}"

Expected behavior

The code above should render a working link, correctly formatted, like this:

Screenshot 2021-03-18 at 16 35 05

Resulting behavior

The HTML appears inline in the corresponding view.

Screenshot 2021-03-18 at 16 35 50


Solutions

We were able to get the links working correctly with either == or ! (examples below). We ultimately went with the bang method (!), but neither option successfully bypassed our Prettier checks.

%mj-text
    == "Link your Twitter, Slack, and GitHub accounts today. #{link_to 'Set up integrations >', user_settings_url(@user)}"

With the bang method, we're able to prevent interpolation escaping. More info here.

%mj-text
    ! Link your Twitter, Slack, and GitHub accounts today. #{link_to 'Set up integrations >', user_settings_url(@user)}

We were able to get everything to work by adding the file in question to our Prettier ignore file.

@sighmon
Copy link
Owner

sighmon commented Sep 11, 2021

@alexlsalt Sorry for the huge delay... did you have any suggestions for changes in mjml-rails? I don't use HAML, so it'd be great if you wanted to put together a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants