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

Add support mjml in email.html.twig #74

Merged

Conversation

kuzmany
Copy link
Member

@kuzmany kuzmany commented Apr 24, 2021

This should fix this mautic/mautic#9676
At the moment If you want use MJML you need add to your template email.mjml.twig.

After this PR your template should have email.html.twig with MJML. This allow upload template without issue.
State before I marked as deprecated, we should rename email.mjml.twig to email.html.twig and note it to documentation.

Steps to tests:

  1. Delete brienz theme and upload modified them with renamed email.mjml.twig to email.html.twig
    brienz.zip

  2. Try If template works like before

@RCheesley
Copy link
Sponsor Member

I tried to upload the file attached but still getting the same warning:

screenshot-mautic4 ddev site-2021 04 24-18_21_03

@RCheesley
Copy link
Sponsor Member

Maybe the file was not renamed? Or did you mean that we should unzip, rename and upload?

screenshot-nimbus-capture-2021 04 24-18_25_56

Copy link
Sponsor Member

@RCheesley RCheesley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed by testing with the theme provided and renaming the MJML file to HTML allowed me to upload the theme, and when I work with the template in the GrapesJS builder I am seeing the MJML markup when I click to view the code mode.

@kuzmany
Copy link
Member Author

kuzmany commented Apr 24, 2021

Seems does not work on edit, even If MJML was stored. I will check it

@kuzmany
Copy link
Member Author

kuzmany commented Apr 24, 2021

@RCheesley without this PR there is a bug with MJML at current version? If create mjml email, then save & close, then try open builder - open HTML version of editor for me? Can you test it?

@RCheesley
Copy link
Sponsor Member

@kuzmany yes I can reproduce that - as soon as I close the builder, without saving the email, it is in HTML - https://youtu.be/yKyTn4qqObI

@kuzmany
Copy link
Member Author

kuzmany commented Apr 25, 2021

@adiux I suppose issue coming from this condition

const canvasContent = fullHtml.body.innerHTML

Should be something

const canvasContent = mQuery('textarea.builder-mjml').val() ? mQuery('textarea.builder-mjml').val() : fullHtml.body.innerHTML;

How it works on dev mode? I need run npm run build on on every change? Could you look on it?

@kuzmany
Copy link
Member Author

kuzmany commented Apr 25, 2021

@RCheesley @adiux this should fixed it #76. Can you test also this PR?

@kuzmany kuzmany requested a review from RCheesley April 25, 2021 12:09
@RCheesley
Copy link
Sponsor Member

  1. Delete brienz theme and upload modified them with renamed email.mjml.twig to email.html.twig
    brienz.zip

@kuzmany when I try to upload this file, with this PR applied, I am still getting the error:

The theme you tried to install is missing the following required files and thus could not be installed: html/email.html.twig

What is this PR supposed to be addressing?

The goal is that folk can upload a theme that is just MJML I think (eg email.mjml.twig), but maybe I am missing something here - did you change it so that the file can be email.html.twig but still contain only MJML?

Would really appreciate some clarity on this both for testing the PR but also for the docs that @jos0405 is working on.

@kuzmany
Copy link
Member Author

kuzmany commented Apr 30, 2021

@RCheesley I uploaded wrong theme
brienz.zip

Now MJML code is paste directly in email.html.twig - this is my change.
If you want standard HTML editor for email you just put HTML to email.html.twig. If you need MJML editor for email, you just put MJML to email.html.twig.
Code detect syntax and choose builder based on that.

@RCheesley
Copy link
Sponsor Member

Awesome - works great with that installer for the theme - was able to create the theme, and MJML markup is retained after saving also. There is still the issue with the device preview but will raise that as a separate issue.

@RCheesley RCheesley merged commit 491ac36 into mautic:mautic3x Apr 30, 2021
@mautibot
Copy link

This pull request has been mentioned on Mautic Community Forums. There might be relevant details there:

https://forum.mautic.org/t/theme-missing-email-html-twig/20665/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants