Frequently Asked Question

Templates
Last Updated 7 days ago

Templates

Templates are text files, which can contain plain text, or html, and have within them embedded substitutions within {{ and }}.

An example substitution would be {{name}} which will then be replaced at generate time by providing "name":"fred" in the json data.

There are a number of system substitutions which are prefixed with system. and these are detailed below.

For the purposes of HTML email, all images *should* be included as base64 encoded data rather than remote images, because many email clients will block these now.

Anywhere Goes

Substitution can happen anywhere in the document, and in the email subject line. You can leverage substitution to control things like html classes, styles and mode, but be aware that you cannot include " in these variables (limitations of JSON). You can for example have:

  This is the message

Assuming you've defined the value of msgclass in the style section of the document. You can use styles also:

  Message

Anything Goes

You can supply html as a substitution, for example {{table1}} could be substituted with the HTML for a table with content. This is used extensively to provide tabular content into templates. Care should be taken to properly encode any HTML so it doesn't corrupt the JSON and cause failures.

The flexibility is almost limitless, and once the template is registered, generating emails is extremely simple. The majority of GEN's notification emails are generated using this framework

System Substitution Parameters

The following system parameters can be used in templates using the syntax {{system.parameter_name}}:

Parameter Description Example Output
ukdate Current date in UK format 31/12/2023
12time Current time in 12-hour format 11:59 PM
24time Current time in 24-hour format 23:59
isodate Current date in ISO format 2023-12-31
nicedate Current date in a readable format Sunday, December 31, 2023
dayofweek Current day of the week Sunday
daynumber Current day of the month 31
monthname Current month name December
year Current year 2023
timestamp Current date and time 2023-12-31 23:59:59
shortdate Current date in short format 31-Dec-23
rfc2822date Current date in RFC 2822 format Sun, 31 Dec 2023 23:59:59 +0000
monthnumber Current month number 12
dayofyear Current day of the year 365
weekofyear Current week of the year 52
quarter Current quarter of the year Q4
company Company name Global Enterprise Networks

Apply

These system parameters can be used in both the email body and subject line.

Concatenation and Placement

There is no white-space introduced around substitutions, allowing concatenation, for example {{system.quarter}}{{system.year}} would render Q42024.

This website relies on temporary cookies to function, but no personal data is ever stored in the cookies.
OK
Powered by GEN UK CLEAN GREEN ENERGY

Loading ...