Skip to content

Tag: for

Chris Talman edited this page Aug 29, 2016 · 4 revisions

The for tag allows use of any kind of JavaScript for statement.

While the each tag is appropriate in most cases, the for tag allows greater autonomy in cases where greater complexity is required.

Syntax

{{for expression}}
	contents
{{/for}}

Example: For Statement

{{for i = 0; i < 3; i++}}
	{{print i}}
{{/for}}

This would output the following.

0
1
2

Example: For Of Statement

{{for i of array}}
	{{print i}}
{{/for}}

This would output the following given data object {array: ['a', 'b', 'c']}.

a
b
c
Clone this wiki locally