mjmlio / vscode-mjml

MJML preview, lint, compile for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=attilabuti.vscode-mjml
MIT License
178 stars 24 forks source link

Allow to preview partial MJML files #18

Closed md-turismoi closed 3 years ago

md-turismoi commented 3 years ago

Previous version only allow to preview complete and well-formed MJML files (....). This version allows also to preview partial MJML files (...) to be able to create dynamic layouts splitting shared headers/footers in different files and include them in run-time.

`

THIS IS A PREVIEW OF A PARTIAL MJML FILE !!!!

`

Daniel-Knights commented 3 years ago

Only issue with this is styles don't carry over, not sure if there's a way around that

Daniel-Knights commented 3 years ago

Also, if, on the off-chance, someone added a comment:

<!-- <mjml> -->

It wouldn't work.

Unlikely, but still a possibility.

md-turismoi commented 3 years ago

That's right. tag don't carry over if there is no .

This feature was designed for scenarios where you have different kinds of emails in your project, you might want to extract some of the shared logic into something you could reuse (email header & footer, replacing dynamically only the body or some sections). In that case, the partial MJML files should not include the shared markups: baseLayout.mjml `

<%= render partial: 'foobar_header', formats: [:html] %> Hello <%= @name %>

`

footer_header.mjml `

THIS IS A PREVIEW OF A PARTIAL MJML FILE !!!!

`

kmcb777 commented 3 years ago

@md-turismoi Hi, thanks for this PR and sorry for the wait. This is useful indeed, but in the mjml-app we have an equivalent feature to allow partials rendering, and we check it like this : if(documentText.trim().startsWith('<mjml')) I'd prefer it to be the same here, could you please just change this ?