sighmon / mjml-rails

MJML + ERb/Haml/Slim view template
https://mjml.io
Other
300 stars 65 forks source link

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

Open jitinmaher opened 5 years ago

jitinmaher commented 5 years ago

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 )

sighmon commented 5 years ago

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

jitinmaher commented 5 years ago

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

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

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

sighmon commented 5 years ago

@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 commented 5 years ago

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