Closed wannevancamp closed 5 months ago
hi
thanks for this great idea
so i think frosh also uses twig. that means snippets have a different syntax? or do you need same snippet twig syntax with a different file extension?
thanks
The FroshPlatformTemplateMail plugin supports MJML formats which makes styling emails much easier. In those templates, the MJML extension is used instead of twig.
Example folder structure with MJML files.
MJML content with snippets.
<mjml>
<mj-body mj-class="body">
<mj-wrapper mj-class="body__wrapper">
<mj-section mj-class="content">
<mj-column>
<mj-text>
<h1>{{ 'email.contact.subject'|trans|sw_sanitize }}</h1>
<p>{{ 'email.contact.intro'|trans|sw_sanitize }}</p>
...
</mj-text>
</mj-column>
</mj-section>
</mj-wrapper>
</mj-body>
</mjml>
In this example the snippets in the MJML file are not detected by the twig-scanner.
email.contact.subject
email.contact.intro
Hi
a perfect
thats amazing so we have a a) a new extension b) new snippet pattern in that files
great
ill do it
thanks a lot :)
you can test dev-master with the new scanner should work now, QA not started yet but unit tests are all passing
Thanks for the fast response!
I've tested the feature on the dev-main branch but it still does not recognize the .mjml
files? Do I have to activate to MJML-scanner?
#1 [EMPTY_CONTENT] Found empty translation
- Locale: en-GB
- File: /.../.../.../.../src/xyz/Resources/snippet/storefront.en-GB.json
- Line: 30
[x]: email.contact.intro
you need to use the scanner:usage command the detection in files is integrating with an external system from the frameworks point of view (so twig files) and its not 100% correct...because snippets might not appear inside templates but could be used inside PHP scripts....
so the basic idea on scanners is to get some quick insight in what MIGHT not be used :)
php bin/console scanner:usage .... --scanner=mjml --dir=xyz
that should work
I'm running php vendor/bin/phpunuhi scan:usage --dir=./src --scanner=mjml --set=General
but still get the following errors:
+-------+----------------------------------------------------+----------------------------------------------------------------------------------+
| # | Keys (2) | Error |
+-------+----------------------------------------------------+----------------------------------------------------------------------------------+
| 1 | email.contact.intro | Key not found in any file |
| 2 | email.contact.subject | Key not found in any file |
This is my simplified configuration
Ok that's funny because of these unit tests with the exact same data haha https://github.com/boxblinkracer/phpunuhi/blob/main/tests/phpunit/Bundles/Scanner/MJML/MjmlScannerTest.php
could only think of the file not being found somehow
ill check it out...maybe ill add a debug output which files have been scanned would be good right? or a verbose mode for that maybe?
Hi
ok got it, stupid me. forgot to ask the scanner implementation what file extension to use accidentally always used TWIG
now its dynamic and should work in dev-master :)
Great, I've tested the fix on the dev-main and it works 👍
The last step to make the CI validation work is the compatibility for mjml with the validate:all
command. I suppose it's better to create another ticket for this?
Hi amazing thank you
yeah i didnt really want to add the scanners to the official validation command because the result is not 100% valid....please see the warnings in the text
if snippets are added thru PHP for instance...then its okay that they are not found in those files. so scanners are more some working helpers.....
do you have any better idea on that?
released in 1.17.0
When using MJLM templates with snippets, snippets are not detected because a MJML scanner is currently not supported. This can be very useful when using the Shopware plugin FroshPlatformTemplateMail