Comprehensive guide to building custom templates using Handlebars templating engine, schemas, blocks, and advanced configuration options
{{#schema}}
and {{/schema}}
parts of the template - usually at the end.
id
attribute determines the title shown in the admin when selecting the template.
name
attribute determines the title shown in the admin when selecting the template.
description
attribute determines the description shown in the admin when selecting the template.
preview_image_url
attribute determines the preview image shown in the admin when selecting the template. This helps users to visually see what your template will look like.
type
attribute determines whether the template is for content or recommendations. This affects which part of the template picker the template appears in.
content
- The template will be used for content (not recommendations)recommender
- The template can only be used to show recommendationssettings
attribute defines the customizations that a client can make. They provide the properties that are available when creating a campaign.
blocks
attribute defines an array of block
, reusable content available in a template. Blocks are reusable modules of content within a template that can be added, removed, and reordered when creating a campaign.
max_blocks
attribute defines the maximum number of blocks that can be added when creating a campaign with the template. This is shown on the “Add Block” button when creating a campaign.
min_blocks
attribute defines the minimum number of blocks that must be added when creating a campaign with the template.
default
attribute defines default values that will be displayed when creating a campaign from a template. This is an array of block types, such as ["image", "description", "button"]
.
block
multiple timestype
attribute is a user defined value, useful when looping over blocks in the template to specify different HTML for the different blocks.
name
attribute determines the title shown in the admin when selecting the block type.
sub_blocks
attribute defines an array of sub_block
. Sub-blocks are reusable modules of content within a block
within a template that can be added, removed, and reordered when creating a block.
settings
attribute defines the customizations that a client can make. They provide the properties that are available in the admin GUI.
max_blocks
attribute on a block defines the maximum number of sub-blocks that can be added when creating a campaign with the template.
min_blocks
attribute on a block defines the minimum number of sub-blocks that must be added to the block when creating a campaign with the template.
max_instances
attribute defines the maximum number of this type of block that can be added when creating a campaign with the template. This is distinct from the top level max_blocks
as it applies only to this specific block.
min_instances
attribute defines the minimum number of this type of block that must be added when creating a campaign with the template.
block
HTML that provide an extra layer of flexibility. An example of this would be a block that holds a list of links. Each link would be represented by a sub block that could contain a setting for the link text and a setting for the link URL.
type
attribute is a user defined value, useful when looping over sub blocks in the template to specify different HTML.
name
attribute determines the title shown in the admin when selecting the sub block type.
settings
attribute defines the customizations that a client can make. They provide the properties that are available in the admin GUI.
max_instances
attribute defines the maximum number of this type of sub block that can be added when creating a block within the campaign with the template.
min_instances
attribute defines the minimum number of this type of sub block that must be added when creating a block within the campaign with the template.
type
attribute defines the setting type and consequently the GUI that appears in the admin for it.
id
attribute defines the ID used to reference the setting in the template HTML. It must be unique within its current scope.
name
attribute defines the label shown for the setting in the GUI.
description
attribute defines informational text for the setting in the GUI.
default
attribute defines the default value for the setting in the GUI.
info
type outputs as either a header or paragraph in the GUI and is purely informational. Useful for grouping several settings or providing more detailed information.
Attribute | Description | Required |
---|---|---|
content_type | Whether this is a “header” or “paragraph” | Yes |
content | The content to output as a string value | Yes |
checkbox
type outputs as a checkbox field in the GUI. Useful for toggling features on and off. Returns a boolean when referencing in the template HTML.
number
type outputs as a number input field in the GUI.
Attribute | Description | Required |
---|---|---|
placeholder | A placeholder value for the input | Yes |
range
type outputs as a slider field in the GUI. Returns a number when referencing in the template HTML.
Attribute | Description | Required |
---|---|---|
min | The minimum value of the range | Yes |
max | The maximum value of the range | Yes |
step | The increment size between steps of the slider | Yes |
unit | The unit for the slider. For example, you could set px for font-size. | No |
select
type outputs as a select field with options in the GUI. Returns a string when referencing in the template HTML.
Attribute | Description | Required |
---|---|---|
options | An array of objects containing value and label string attributes for each option in the dropdown | Yes |
text
type outputs as a single line text input field in the GUI. Returns a string when referencing in the template HTML.
Attribute | Description | Required |
---|---|---|
placeholder | A placeholder value for the input | Yes |
textarea
type outputs as a multi line textarea field in the GUI. Returns a string when referencing in the template HTML.
Attribute | Description | Required |
---|---|---|
placeholder | A placeholder value for the input | Yes |
colour
type outputs as a dropdown in the GUI. Theme colours can be selected, and if a value of “Custom” is selected, a colour picker is presented to the user. Returns a string when referencing in the template HTML.
category_picker
type outputs as a category picker in the GUI, allowing you to select a category from the information uploaded to PureClarity in the Category feed. Returns a category
object when referencing in the template HTML.
product_picker
type outputs as a product picker in the GUI, allowing you to select a product from the information uploaded to PureClarity in the Product feed. Returns a product
object when referencing in the template HTML.
html
type outputs as a multi-line textarea in the GUI, allowing you to enter HTML markup. Returns a string when referencing in the template HTML.
Attribute | Description | Required |
---|---|---|
placeholder | A placeholder value for the input | Yes |
image_picker
type outputs as an image picker in the GUI, allowing you to select an image that has been uploaded to PureClarity, or an external URL. Also allows the alt text to be specified. Returns an object when referencing in the template HTML.
Property | Type | Usage |
---|---|---|
src | string | The image URL |
height | number | Height of the image (automatically determined) |
width | number | Width of the image (automatically determined) |
aspect_ratio | number | Aspect ratio of the image (automatically determined) |
alt_text | string | Optional alt text for the image (if specified by user) |
font
type outputs as a selection of font related options in the GUI, such as font family to use, font size and font size unit options, line height etc. Returns an object when referencing in the template HTML.
Property | Type | Usage |
---|---|---|
font_family | string | A font to use |
font_size | string | Value of the font size (10, 24 etc) |
font_size_unit | string | The unit to use for the font size (px, em, rem etc) |
font_weight | string | Font weight, using the humanised values (bold, normal, thin etc) |
text_transform | string | Option to transform text (Uppercase, lowercase, capitalise etc) |
line_height | string | Value of the line height (10, 24 etc) |
line_height_unit | string | The unit to use for the line height (px, em, rem etc) |
letter_spacing | string | Value of the letter spacing (10, 24 etc) |
letter_spacing_unit | string | The unit to use for the letter spacing (px, em, rem etc) |
rich_text
type outputs as a multi-line text area with text formatting options in the GUI, allowing you to enter formatted text content. Returns a string when referencing in the template HTML.
url
type outputs as a single line input field in the GUI, allowing you to enter a URL. Returns a string when referencing in the template HTML.
video_url
type outputs as a single line input field in the GUI, allowing you to enter a URL or ID of a YouTube or Vimeo video. Returns a full URL string when referencing in the template HTML.