mjml-rails
mjml-rails copied to clipboard
Variables with html tags inside *.mjml.erb displayed as raw text in email body
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 could you try naming your file *.html.mjml
and let me know if that helps?
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
@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.
we have the same issue. MJML output is rendered to the format.text mails.