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

Variables with html tags inside *.mjml.erb displayed as raw text in email body #45

Open
jitinmaher opened this issue Nov 14, 2018 · 4 comments

Comments

@jitinmaher
Copy link

jitinmaher commented Nov 14, 2018

Do you want to request a feature or report a bug?
Bug

Issue description
We recently upgraded our package mjml-rails from 2.4.1 to 4.2.4 and mjml npm dependency from 3.3.3 to 4.2.0. We have a function doSomeProcessingWithText which accepts name variable, the variable is supposed to be bold so its wrapped with <strong></strong> attribute. With the latest upgrade the output email body doesn't parse tag as html rather it displays it as raw text.

Code snippet

<mj-text>
        <%= doSomeProcessingWithText('%{name} Liked your post') % { name: "<strong>#{@person.name}</strong>" }%>
</mj-text>

What is the current behavior?
<strong>JOHN</strong> Liked your post

What is the expected behavior?
JOHN Liked your post ( notice that JOHN is bold here )

@jitinmaher jitinmaher reopened this Nov 14, 2018
@jitinmaher jitinmaher changed the title Variables with html attributes inside *.mjml.erb Variables with html attributes inside *.mjml.erb displayed as raw text in email body Nov 14, 2018
@jitinmaher jitinmaher changed the title Variables with html attributes inside *.mjml.erb displayed as raw text in email body Variables with html tags inside *.mjml.erb displayed as raw text in email body Nov 14, 2018
@sighmon
Copy link
Owner

sighmon commented Nov 18, 2018

@jitinmaher could you try naming your file *.html.mjml and let me know if that helps?

@jitinmaher
Copy link
Author

jitinmaher commented Nov 30, 2018

Hey @sighmon thanks for your reply. I tried the following things but none worked:

1)- Changed the file name to have extension *.html.mjml

  • Output: couldn't generate email because it failed to find the template giving exception Exception occurred: ActionView::MissingTemplate

2)- Changed the file name to have extension *.mjml

  • Output: <strong>JOHN </strong> Liked your post

@sighmon
Copy link
Owner

sighmon commented Dec 7, 2018

@jitinmaher Hmmmm weird... could you try setting: config.raise_render_exception = true to your mjml.rb initializer and see if there's any more error output?

# config/initializers/mjml.rb
Mjml.setup do |config|
  config.template_language = :erb # :erb (default), :slim, :haml, or any other you are using
  config.raise_render_exception = true
end

If you'd like to build a sample project showing your problem and upload it to github, I can help debug further.

@voordev
Copy link

voordev commented Dec 19, 2018

we have the same issue.
MJML output is rendered to the format.text mails.

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

3 participants