autoescape

The autoescape tag can be used to temporarily disable/re-enable the autoescaper as well as change the escaping strategy for a portion of the template.

Example

{% autoescape "js" %}
${content}
{% endautoescape %}

block

A section that can be overridden by a child template.

Template

{% block "${blockName}" %}
${content}
{% endblock %}

extends

The extends tag is used to declare a parent template. It should be the very first tag used in a child template and a child template can only extend up to one parent template.

Template

{% extends "${templateName}" %}

filter

The filter tag allows you to apply a filter to a large chunk of template.

Template

{% filter ${filter} %}
${content}
{% endfilter %}

Template 2

{% filter ${filter1} | ${filter2} %}
${content}
{% endfilter %}

for

The for tag is used to iterate through a collection or map.

Template

{% for ${i} in ${collection} %}
${content}
{% endfor %}

for else

The for tag is used to iterate through a collection or map with a convenient way to check for emptiness.

Template

{% for ${i} in ${collection} %}
${content}

{% else %}
${content}

{% endfor %}

if

The if tag allows you to designate a chunk of content as conditional depending on the result of an expression.

Template

{% if ${condition} %}
${content}
{% endif %}

if else

The if tag allows you to designate a chunk of content as conditional depending on the result of an expression.

Template

{% if ${condition} %}
${content}
{% else %}
${content}
{% endif %}

if elseif

The if tag allows you to designate a chunk of content as conditional depending on the result of an expression.

Template

{% if ${condition} %}
${content}
{% elseif %}
${content}
{% else %}
${content}
{% endif %}

import

The import tag allows you to use macros defined in another template.

Template

{% import "${templateName}" %}

include

The include tag allows you to insert the rendered output of another template directly into the current template. The included template will have access to the same variables that the current template does.

Template

{% include "${templateName}" %}

include with

The include tag allows you to insert the rendered output of another template directly into the current template. The included template will have access to the same variables that the current template does with additional variables.

Template

{% include "${templateName}" with { ${mapOfVariables} } %}

macro

The macro tag allows you to create a chunk of reusable and dynamic content. The macro can be called multiple times in the current template or even from another template with the help of the import tag.

Example

{% macro concat(left, right) %}
{{ left }} {{ right }}
{% endmacro %}

parallel

The parallel tag allows you to designate a chunk of content to be rendered using a new thread.

Template

{% parallel %}
${content}
{% endparallel %}

set

The set tag allows you to define a variable in the current context, whether it currently exists or not.
Will initialize the variable or override the current value in the variable.

Template

{% set ${variable} = ${value} %}

verbatim

The verbatim tag allows you to write Pebble syntax that won't be parsed.

Example

{% verbatim %}
{% if not varA is defined %}
{% set varA = "Abc" %}
{% endif %}
{% endverbatim %}

br

The br tag adds a line break token at the current position.
Use an additional parameter to change the type of line break: lf (Default), crlf, other "token".

Template

{% br %}
{% br lf %}
{% br crlf %}
{% br other "|" %}

counter

The counter tag outputs an integer value that is incremented by one for each use.
Use the parameter local to make the counter increments per used template.

Example

{% counter %} pencil
{% counter %} pens

Output

1 pencil
2 pens

Example 2

Template "Other": {% counter local %}
Main template: {% counter local %}{% include "Other" %}

Outputs

11

declare

The declare tag allows you to define a variable in the current context if it does not exist. If the variable does exist it will not be changed.

Note

The following are the same:

{% declare encapsulation = true %}
{% set encapsulation = encapsulation | default(true) %}


Example

{% set varA = "aa" %}
{% declare varA = "bb" %}
{% declare varB = "cc" %}
{{ varA }} {{ varB }}

Outputs

aa cc

error

The error tag allows you to fail generating the template with an error message, e.g. if something unexpected occurs.

Example

{% if not requiredVar is defined %}
{% error "Something terrible has occurred" %}

indent

The indent tag adds one or more 4-space indents at the current position.

Example

{% indent %}

Example 2

{% indent 3 %}

from

The from tag is used to iterate a subset of a collection defined by the where condition.

Template

{% from ${collection} as ${var} where ${test} %}
${content}
{% endfrom %}

Example

{% from range(1,10) as num where num is even %}
{{- num }}{% br %}
{% endfrom %}

Output

2
4
6
8
10

from else

The from tag is used to iterate a subset of a collection defined by the where condition with a convenient way to check for emptiness.

Template

{% from ${collection} as ${var} where ${test} %}
${content}
{% else %}
${content}
{% endfrom %}

Example

{% from [] as num where num is even -%}
Even numbers{% br %}
{% else -%}
Empty collection{% endfrom %}

Output

Empty collection

list add

The list with add tag is used to append a value to a list.

Example

{% set alphabet = ["a", "b", "c"] %}
{{ alphabet }}{% br %}
{% list alphabet add "d" -%}
{{ alphabet }}

Outputs

[a, b, c]
[a, b, c, d]

list adds

The list with add tag is used to append one or more values to a list.

Example

{% set alphabet = ["a", "b", "c"] %}
{{ alphabet }}{% br %}
{% list alphabet add "d", "e", "f" -%}
{{ alphabet }}

Outputs

[a, b, c]
[a, b, c, d, e, f]

list remove

The list with remove tag is used to remove a value from a list.

Example

{% set alphabet = ["a", "b", "c", "d", "e", "f"] %}{{ alphabet }}{% br %}{% list alphabet remove "d", "e", "f" -%}
{{ alphabet }}

Outputs

[a, b, c, d, e, f]
[a, b, c]

list removes

The list with remove tag is used to remove one or more values from a list.

Example

{% set alphabet = ["a", "b", "c", "d", "e", "f"] %}
{{ alphabet }}{% br %}
{% list alphabet remove "d", "e", "f" -%}
{{ alphabet }}

Outputs

[a, b, c, d, e, f]
[a, b, c]

map put

The map put tag is used to set a key-value pair into a map, whether it currently exists or not.

Template

{% map ${mapVar} put ${key} = ${value} %}

map remove

The map remove tag is used to remove a key from a map.

Template

{% map ${mapVar} remove ${key} %}

placebottom

The placebottom tag allows defining a block in the template that will be placed at the end of the output. The priority argument defines the order of multiple place bottom blocks.

Template

{% placebottom ${priority} %}
${content}
{% endplacebottom %}

get

The get tag defines a variable as a subset of a collection based on the given condition.

Example

{% get evenNums from range(1,10) as num where num is even %}
{{ evenNums }}

Output

[2, 4, 6, 8, 10]

  • No labels