asahasrabuddhe / laravel-mjml

Easily use MJML in your Laravel Blade templates!
MIT License
122 stars 51 forks source link

Request: blade processing of <mj-include>-ed files #144

Closed tennox closed 1 year ago

tennox commented 1 year ago

It would be great to be able to use blade templating also in the files which are included via <mj-include>, but I guess this is a bit difficult, as the blade templating is run before the file is passed to MJML.

One option would be to do it the other way around, but I'm not sure if this would break other use-cases like controlling MJML via blade code first - I could think of a conditional include or adding styling from blade variables, ...

So I thought another option could be to have a folder with MJML partials to be included, and to process them with Blade too, putting them in a subfolder of the compiled views (and using it as --config.filePath), and thus enabling to import the blade-rendered files. :tada:

What do you think? Feasible? Useful? Better idea?

Might work on a PR if we agree on a solution.

tennox commented 1 year ago

Oh, I just realized I can extend & include using blade, probably that's the easiest solution... And mj-includes only for things that don't need templating.

I will try this concept and re-open if I still see a need for it.