stidges / laravel-mix-mjml

Laravel Mix plugin to compile MJML files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blade directives being stripped out

liran-co opened this issue · comments

It looks like we can't use any blade directives like @if ... @endif. When the views are compiled, it's stripping these out in the final blade file. Is there anyway to tell MJML not to strip these out?

MJML will strip out any content outside of the tags. To work around this you can try wrapping your blade directives inside an <mj-raw></mj-raw> tag, for example:

<mjml>
  <mj-body>
    <mj-raw>@if ($foo === 'bar')</mj-raw>
      <mj-section>
      <mj-column><mj-text>Foo</mj-text></mj-column>
      </mj-section>
    <mj-raw>@endif</mj-raw>
  </mj-body>
</mjml>

Ah okay, that works! I wonder if there is a way to automatically wrap any blade directives with <mj-raw> - thoughts?

I'm going to hold off on that for now I think, as it would introduce a lot of complexity in the plugin to parse out Blade directives, especially when having to ignore directives that are placed within specific nodes like <mj-text />.