Template and helpers

Use Handlebars power to generate newsletters.

Template

In this section you describe your newsletter body using Handlebars templating. With {{expression}} you will have access to all the data you query in the GraphQL section as well as helpers you may have specified. Good to know, by default Handlebars will escape values returned by {{expression}}

Note: If you don't want Handlebars to escape a value (& in url for example), use the "triple-stash" {{{expression}}}.

Example

<table>
<tr>
<td>
{{#if summary}}
{{{summary}}}
{{else}}
Hello, welcome in your daily newsletter
{{/if}}
</td>
</tr>
</table>
{{#if zone1Articles}}
<table>
<tr>
<td>{{{firstArticleArea.0.title}}}</td>
</tr>
<tr>
<td>
{{#if firstArticleArea.0.image}}
<img
class="img"
src="{{firstArticleArea.0.image.url}}"
width="{{firstArticleArea.0.image.width}}"
height="{{firstArticleArea.0.image.height}}"
alt="{{firstArticleArea.0.image.alt}}" />
{{/if}}
{{#each firstArticleArea.0.nodes}}
{{#isEqual textNode.type 'paragraph'}}
<p class="nl-article-nodes{{#if @last}} nl-article-nodes-last{{/if}}">
{{{addDataLinks textNode.text 'zone-1'}}}
</p>
{{/isEqual}}
{{#isEqual textNode.type 'bulletedList'}}
<ul class="nl-article-nodes{{#if @last}} nl-article-nodes-last{{/if}}">
{{{addDataLinks textNode.text 'zone-1'}}}
</ul>
{{/isEqual}}
{{/each}}
</td>
</tr>
</table>
{{/if}}

Helpers

The last editing section allows you to define utility variables and functions for your Handlebars template. You can find more about helpers in Handlebars documentation.

Helpers run on the current LTS version of Node.js, it means all new features of JavaScript are usable.

Edit this page on GitHub