Flowmailer uses Freemarker as the basis of the templating engine. To reuse certain elements of templates, Freemarker works with so-called 'macros'.
Freemarker macros are blocks of Freemarker template code that can be defined and then reused in multiple places within a template. They can be useful for creating complex templates with a high degree of modularity and reducing templates' duplication.
To use Freemarker macros in email templates, you can follow these steps:
-
Define the macro in the template. To define a macro, you can use the <#macro> tag, followed by the macro's name and a list of parameters. The code inside the <#macro> and </#macro> tags is the body of the macro.
-
Call the macro in the template. To call a macro, you can use the <#include> tag, followed by the name of the macro and a list of arguments. The arguments are used to pass data to the macro when it is called.
Here's an example of a Freemarker macro that could be used in an email template to generate a button:
<#macro button url label>
<tableborder="0" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
<a href="${url}" target="_blank" style="display: inline-block; padding: 8px 16px; background-color: #002a4d; color: #ffffff; font-size: 16px; font-weight: bold; line-height: 24px; text-decoration: none; border-radius: 4px;">${label}