jdrouet / mrml

Implementation of mjml in rust
MIT License
330 stars 19 forks source link

<mj-font> tag not valid anymore? #356

Closed paulgoetze closed 8 months ago

paulgoetze commented 8 months ago

Hey @jdrouet, I was updating the Elixir mjml_nif package to use mrml v2.1.1 and saw an issue with rendering previously valid MJML templates that included an <mj-font> tag. (Also see https://github.com/adoptoposs/mjml_nif/issues/119)

It looks like if I remove the <mj-font> tag from the template and instead pass the fonts render option, then rendering works again as expected.

Is the <mj-font> tag not handled anymore in v2.1.1 or should either way of configuring fonts in the MJML template work?

jdrouet commented 8 months ago

it should, I'll take a look at that, thanks for noticing!

jdrouet commented 8 months ago

After looking at it, <mj-font {...attrs} /> is the expected behavior. But I can add the behavior for <mj-font {...attrs}></mj-font>.

paulgoetze commented 8 months ago

@jdrouet Ooh, alright. I just checked again with the self-closing tag and it looks like the issue is how the Elixir template engine renders an embedded template: It turns <mj-font ... /> into <mj-font ...></mj-font> (https://github.com/phoenixframework/phoenix_live_view/issues/1596), which is now an invalid format when passed to mrml.

Is there other self-closing tags that are handled similarily? I could see e.g. <mj-divider /> and <mj-image /> work and do not throw errors, even though they got changed to <mj-divider ...></mj-divider> and <mj-image ...></mj-image> respectively in Elixir before passing it to mrml.

jdrouet commented 8 months ago

That's weird, mj-image and mj-divider are implemented exactly the same way 🤔

paulgoetze commented 8 months ago

That was amazingly fast! Thanks, Jérémie, for the fix and all the good work you put into mrml! :heart: