- Front Matter
- Your HTML
Front Matter
Templates can define new variables and even override existing ones from your config, through the optional YAML-style Front Matter block:emails/example.html
page object.
To output them in a Template, use the {{ }} expression syntax:
emails/example.html
Expressions
Expressions in Front Matter can be ignored with a@ symbol when they’re used in the Template they’re defined in:
emails/example.html
build_production/example.html
Using Layouts
Your emails will likely share the same boilerplate, like the<!doctype>, the <head> with all the <meta> tags, or the <body> tag - code that rarely needs to change.
Although you’re free to do it, it would be very inefficient to always have to write this boilerplate every time you create a new Template.
To reuse this code in Maizzle, you may create a Layout:
layouts/main.html
emails/example.html
<x-main> Component tag to say that we want to use the main.html Layout. At build time, the <yield /> tag in the Layout file is replaced with what’s inside the <x-main> tag in our Template.
Learn more about how these x-tags work, in the Components docs.
Current template
Information about the Template file that is currently being processed will be available underpage.build.current:
beforeRender if you need the file name or extension of the Template file currently being processed.
Current template file information is not available when using the API.
Archiving
Maizzle will only compile Templates found at paths defined inbuild.content.
If your project has a lot of emails, your builds may start to slow down since all Templates are rebuilt on cold start (every time you run the maizzle build <env> command).
You can archive Templates in a few ways:
Change file extension
Change their file extension so that it’s not covered by paths from
build.content