我正在使用 Mjml 和 Twig 为 Prestashop 开发电子邮件模板主题,现在我需要将mjml .twig模板转换为html .twig模板:
welcome.mjml.twig -------- welcome.html.twig
account.mjml.twig --------- account.html.twig
order_conf.mjml.twig ----- order_conf.html .twig
模板.mjml.twig------ 模板.html.twig
为此,Prestashop 团队创建了一个完全可以做到这一点的工具(https://github.com/PrestaShop/mjml-theme-converter),但是一旦我运行以下命令,就会出现“无法转换 mjml 文件”错误:
$ ./bin/console prestashop:mail:convert-mjml simple_mjml ./simple_mjml
错误出现在MjmlConverter.php(第 122 行)上,一旦追踪,它似乎来自 Symfony TemplateNameParser.php(第 75 行)
https://github.com/PrestaShop/mjml-theme-converter/blob/master/src/AppBundle/Mjml/MjmlConverter.php https://github.com/symfony/symfony/blob/3.4/src/Symfony/Bundle /FrameworkBundle/Templating/TemplateNameParser.php
Usuario@PC-DANIEL MINGW64 /v/WEB/PRESTASHOP/EMAIL/DESARROLLO/mjml-theme-converter (master)
$ ./bin/console prestashop:mail:convert-mjml simple_mjml ./simple_mjml -vvv
Converting template account.mjml.twig
08:17:21 INFO [php] User Deprecated: Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.
[
"exception" => ErrorException {
#message: "User Deprecated: Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0."
#code: 0
#file: "V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser.php"
#line: 75
#severity: E_USER_DEPRECATED
trace: {
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser.php:75 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser.php:53 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\Loader\FilesystemLoader.php:82 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\twig\twig\src\Loader\FilesystemLoader.php:150 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\twig\twig\src\Environment.php:299 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\twig\twig\src\Environment.php:381 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigEngine.php:131 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigEngine.php:50 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\src\AppBundle\Converter\TwigTemplateConverter.php:310 {
› \r
› $renderedLayout = $this->engine->render($conversionTemplatePath);\r
› //Transform back {{ }} statements\r
}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\src\AppBundle\Converter\TwigTemplateConverter.php:189 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\src\AppBundle\Converter\TwigTemplateConverter.php:161 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\src\AppBundle\Command\ConvertMJMLThemeCommand.php:105 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:255 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:1010 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:86 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:255 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:74 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:148 { …}
V:\WEB\PRESTASHOP\EMAIL\DESARROLLO\mjml-theme-converter\bin\console:27 { …}
}
}
]
In MjmlConverter.php line 122:
[AppBundle\Mjml\MjmlException]
Could not convert mjml file