Conditionals
You can use if/elseif/else conditionals in your email templates. For example, the Starter uses it to output a preheader in its Layout:emails/example.html
emails/example.html
Custom conditionals tag
You may customize the conditional tag names:config.js
emails/example.html
Template
The<template> tag will only return its contents.
You can use it to apply a filter to a string, for example:
emails/example.html
emails/example.html
Preserving template tags
If you actually need to output a<template> tag in the compiled HTML, you may use the preserve attribute:
emails/example.html
Outlook
Wrap content in MSO conditional comments to show it only in Outlook 2007-2021 on Windows:emails/example.html
emails/example.html
<outlook> tag supports various combinations of attributes that will help with showing or hiding content in specific Outlook versions:
only- show only in these Outlook versionsnot- show in all versions except theselt- all versions before this (not including it, i.e. lower than)lte- all versions before this (including it, i.e. lower than or equal to)gt- all versions after this (not including it, i.e. greater than)gte- all versions after this (including it, i.e. greater than or equal to)
emails/example.html
only and not attributes support multiple values, separated with a comma:
emails/example.html
emails/example.html
Custom Outlook tag
Of course, you may customize the<outlook> tag name:
config.js
emails/example.html
Switch
Need to use a switch statement?emails/example.html
Custom switch tag
You may define custom tags for the switch statement:config.js
emails/example.html
Loops
You can iterate over arrays and objects with the<each> tag.
For arrays:
emails/example.html
emails/example.html
Loop meta
Inside a loop you will have access to a{{ loop }} object that contains information about the loop currently being executed:
loop.index- the current iteration of the loop (0 indexed)loop.remaining- number of iterations until the end (0 indexed)loop.first- boolean indicating if it’s the first iterationloop.last- boolean indicating if it’s the last iterationloop.length- total number of items
emails/example.html
Custom loop tag
You may customize the name of the loop tag:config.js
<for> tag instead:
emails/example.html
Scope
Use<scope> tags to provide a data context to the content inside.
Imagine we had this data in our config.js:
config.js
emails/example.html
Custom scope tag
You may customize the<scope> tag name:
config.js
emails/example.html
Fetch
You can fetch and display remote content in your email templates:emails/example.html
<fetch> tag, you have access to a {{ response }} variable.
Fetch options
You may use thefetch key to customize options:
config.js
Raw
Need to skip tag and expressions parsing in a whole block?emails/example.html
build_production/example.html
Custom raw tag
The<raw> tag name may be customized:
config.js
emails/example.html
Env
You may output content based on the current Environment through the<env:> tag:
emails/example.html
maizzle build production will output:
emails/example.html
maizzle build production will remove that block from the output, but it will be shown when you run maizzle build or maizzle serve.