Templates

Handlebars syntax

Write {{variable}} placeholders, {{#if}} branches and {{#each}} loops, then pass template_variables on the send call. PostFrame renders the template on the server when the email is dispatched.

What a template can do

  • Variables

    Insert names, order details and any data you pass in with {{variable}}. Values are HTML-escaped by default.

  • Conditions

    Show or hide content with {{#if}} and {{else}} blocks.

  • Loops

    Render a list, such as order lines, with {{#each items}}.

  • A fixed set of helpers

    eq, neq, gt, lt, and, or, not, uppercase, lowercase, truncate and formatDate. Templates run in an isolated Handlebars environment with only these helpers registered.

Syntax examples

{{firstName}}
Simple variable interpolation.
{{#if isPremium}}...{{/if}}
A conditional block.
{{#each orderItems}}...{{/each}}
A loop over an array.
{{uppercase status}}
A built-in text helper.
Questions

PostFrame, answered

Which helpers are available inside a template?

eq, neq, gt, lt, and, or, not, uppercase, lowercase, truncate and formatDate. Only these are registered in the Handlebars environment PostFrame renders with.

How do variables get into the template?

Pass template_id plus a template_variables object on the send call. PostFrame renders the subject and body on the server when the email is dispatched. A variable you leave out uses the default saved on the template, if there is one.

What if the template does not exist?

The send call is accepted and the email is then marked failed with the reason template_not_found. Nothing is sent.

Is there an alternative to Handlebars?

Through the API a template can be stored as React Email. You write JSX, and PostFrame compiles and renders it in a restricted environment to HTML plus a plain-text alternative.

Run your business from one place.

Five plans, 25 launch apps, one dashboard. Change tiers any time.

From $0 · Basic $9.95/mo · Upgrade or downgrade any time