So I'm trying to do what they did over here MJML - Template Interpolation, Dynamic Data, Context but when I run node fun.js
I get the following error.
file:///Users/admin/mjml/mjml/fun.mjs:2
import { compile } from 'handlebars'
^^^^^^^
SyntaxError: The requested module 'handlebars' does not provide an export named 'compile'
Also as a side note are there other ways to template with MJML other than the link above
My code
import { mjml2html } from 'mjml'
import { compile } from 'handlebars'
/*
Compile an mjml string
*/
const template = compile(
`
<mjml>
<mj-body>
<mj-section background-color="#F0F0F0" padding-bottom="0">
<mj-column padding-left="70px" width="250px">
<mj-text font-style="italic" font-size="22px" color="#626262">watFriends</mj-text>
</mj-column>
<mj-column width="170px">
<mj-image width="30px" src={{logo}} />
</mj-column>
</mj-section>
<mj-section background-color="#FAFAFA">
<mj-column width="400px">
<mj-text font-style="italic" font-size="15px" font-family="Helvetica Neue" color="#626262">
Dear {{firstName}},
</mj-text>
<mj-text color="#525252">{{message}}
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
`,
)
const context = {
firstName: '',
message: 'hello',
logo: 'logo.png',
}
const mjml = template(context)
const html = mjml2html(mjml)
console.log(html)