This page documents how FHIR uses the [Liquid language] for templating.

The liquid templating engine is used for the following purposes:

Broadly, FHIR applications that use Liquid templating:


Evaluation Context

Whenever a Liquid template is executed, there's a single object that is the focus that the template is occurring in.

In addition to the focus object, other variables may be provided as specified (where?)

Using Liquid Statements

The following liquid statements are used, with the functionality as documented


A statement consists of 2 pairs of braces with a FHIRPath statement:

 {{ expression }}


 Anything you put between {% comment %} and {% endcomment %} tags
 is turned into a comment.

Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed.


The if control tag is

 {% if expression %}
 {% else %}
 {% endif %}


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

The loop control tag is

 {% loop var in expression %}
   {{ var.expression }}
 {% endloop %}


The for control tag is

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


The else tag specifies a fallback for a for loop which has no elements

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


The include control tag works like this:

 {%include filename parameters %}

e.g. the following include:

 {%loop name in}{%include humanname.html name=name%}{%endloop%}

would lead to a statement like this in the included file: