Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to preview partial MJML files #18

Merged
merged 1 commit into from
Jul 21, 2021
Merged

Allow to preview partial MJML files #18

merged 1 commit into from
Jul 21, 2021

Conversation

md-turismoi
Copy link

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.

<mj-section> <mj-column> <mj-text>THIS IS A PREVIEW OF A PARTIAL MJML FILE !!!!</mj-text> </mj-column> </mj-section>

@Daniel-Knights
Copy link

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

@Daniel-Knights
Copy link

Daniel-Knights commented Mar 24, 2021

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

<!-- <mjml> -->

It wouldn't work.

Unlikely, but still a possibility.

@md-turismoi
Copy link
Author

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] %>

  <!-- Email content -->
  <mj-text>Hello <%= @name %></mj-text>
</mj-container>
`

footer_header.mjml
<mj-section> <mj-column> <mj-text>THIS IS A PREVIEW OF A PARTIAL MJML FILE !!!!</mj-text> </mj-column> </mj-section>

@kmcb777
Copy link
Collaborator

kmcb777 commented Jun 17, 2021

@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 ?

@kmcb777 kmcb777 merged commit f9158c4 into mjmlio:master Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants