sighmon / mjml-rails

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

Invalid mjml silently fails #24

Closed jipiboily closed 6 years ago

jipiboily commented 6 years ago

If you input invalid mjml, mjml-rails doesn't raise any error and just siltenly fails.

Example:

<mj-section>
        <mj-column>
            <mj-text align="left"> Some text for your preheader</mj-text>
        </mj-column>
        <mj-column>
            <mj-text align="right"><a href="email-permalink"> Read in the browser </a></mj-text>
        </mj-column>
      </mj-section>
      <mj-section background-url="https://mjml.io/assets/img/background-url.jpg">
          <mj-column>
              <mj-image src="https://metricswatch.com/wp-content/uploads/2017/04/mwatch-WIP-logo@2x.png"></mj-image>
              <mj-text align="center"> Lorem ipsum </mj-text>
              <mj-button> Discover <%= 2 %> </mj-button>
          </mj-column>
      </mj-section>

This doesn't render and returns nothing (nil or empty string, not sure, didn't check).

It would be relatively easy to catch MJMLError or something like that and raise when we get that from the external rendering through the npm module.

Thoughts?

sighmon commented 6 years ago

@jipiboily When I built this gem, mjml on the command line was failing silently too, so if they've introduced errors now and you can see an easy way to catch them and raise them in Rails, then please do add those changes.

jipiboily commented 6 years ago

It looks like a bunch of errors are still silent.

If I dig into the code again or face silent errors I might tackle this. I don't have much free time right now, though.

sighmon commented 6 years ago

@jipiboily No problems, thanks for checking it out. I'll leave this issue open for the future. :-)

sighmon commented 6 years ago

@jipiboily solved by https://github.com/sighmon/mjml-rails/pull/27