经过大量搜索,我很难找到以下方法:
我以为会有这样的事情:
import { mjml2html } from 'mjml';
const context = {
message: 'Hello World'
};
const view = mjml2html(template, context);<mjml>
<mj-body>
<mj-container>
<mj-section>
<mj-column>
<mj-text>{message}</mj-text>
</mj-column>
</mj-section>
</mj-container>
</mj-body>
</mjml>发布于 2017-03-30 08:24:03
MJML不处理任何模板。如果您想要模板,请使用模板引擎(如工具栏)将其呈现给MJML。
import { compile } from 'handlebars';
import { mjml2html } from 'mjml';
const template = compile(`
<mjml>
<mj-body>
<mj-container>
<mj-section>
<mj-column>
<mj-text>{{message}}</mj-text>
</mj-column>
</mj-section>
</mj-container>
</mj-body>
</mjml>
`);
const context = {
message: 'Hello World'
};
const mjml = template(context);
const html = mjml2html(mjml);https://stackoverflow.com/questions/43111628
复制相似问题