Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note: Loop is deprecated in favor of the For control flow tag

The loop control tag is

 {% loop var in expression %}
   {{ var.expression }}
 {% endloop %}
  • The loop will run once for each object returned by the expression
  • The loop variable is available to expressions using the named parameter
  • Whitespace may be present in the tags, and is not significant.

For

Note: For implementation is in progress as of 5/22/2020

The for control tag is

 {% for var in expression %}
   {{ var.expression }}
 {% endfor %}

...

 {% for var in expression %}
   {{ var.expression }}
{% else %}
The collection is empty. {% endfor %}

Break

The break tag is used to break out of a loop

 {% for var in expression %}
   {{ var.expression }}
{% if expression %}
{% break %}
{% endif %}
{% endfor %}

Continue

The continue tag is used to continue to the next iteration of a loop

{% for var in expression %}
   {{ var.expression }}
{% if expression %}
{% continue %}
{% endif %}
{% endfor %}

Cycle

The cycle tag is used to cycle through a list of items within each iteration of a for loop

 {% for var in expression %}
   {{ var.expression }}
{% cycle "odd", "even" %}
{% endfor %}

Limit

The limit parameter is used in a for loop to limit the number of iterations

 {% for var in expression limit:2 %}
   {{ var.expression }}
{% endfor %}

Offset

The offset parameter is used in a for loop to skip a specified number of iterations

 {% for var in expression offset:2 %}
   {{ var.expression }}
{% endfor %}

Range

Liquid defines a way to iterate a range of numbers (for i in (3..5) but this is ambiguous with FHIRPath grammar and not supported.

Reversed

The reversed tag reversed the order of the elements in the loop

 {% for var in expression reversed %}
   {{ var.expression }}
{% endfor %}

Include

The include control tag works like this:

...