Skip to content

3. Options

Johann Buscail edited this page Oct 17, 2021 · 4 revisions

MJML Options

Path

The absolute path to your MJML file.

Name Required Default Value Type
mjml.path only if property code isn't provided none string

Code

The MJML code.

Name Required Default Value Type
mjml.code only if property path isn't provided none string

Options

You can pass optional options as an object to the mjml2HTMLParser function. Read the official documentation

The absolute path to your MJML file. https://documentation.mjml.io/#inside-node-js

Name Required Default Value Type
mjml.options false {} https://documentation.mjml.io/#inside-node-js

Template Compilation

Engine

You can use multiple template engines in your mjml file:

  • ejs
  • handlebars
  • underscore
  • no-template (no template engine is used to make compilation faster)
Name Required Default Value Type
template.engine false no-template no-template/ejs/handlebars/underscore

Variables

You can pass variables to your template by using the template.vars property:

mjml2HTMLParser({
   template: {
      vars: {
         // Your variables
      }
   }
})
Name Required Default Value Type
template.vars false {} object

EJS Options

Read EJS documentation to know how to use this property

Name Required Default Value Type
template.options false {} https://ejs.co/#docs

Underscore Options

Read Underscore documentation to know how to use this property

Name Required Default Value Type
template.options false {} http://underscorejs.org/#template

Handlebars Options

There are two types of options you can pass to Handlebars:

  • Precompile
  • Runtime

Precompile

Read Handlebars documentation to know how to use this property

Name Required Default Value Type
template.preCompileOptions false {} https://handlebarsjs.com/api-reference/compilation.html#handlebars-compile-template-options

Runtime

Read Handlebars documentation to know how to use this property

Name Required Default Value Type
template.runtimeOptions false {} https://handlebarsjs.com/api-reference/runtime-options