Template tags

Template tags control the output of a template in various ways, and allow the combination of multiple templates into a single output.

fetchxml

Allows user to query data from Microsoft Dataverse, and render the results in a page.

Note

You can learn more about querying the data using fetchxml at use FetchXML to query data.

{% fetchxml resultVariable %}
<!— Fetchxml query -->
...
{% endfetchxml %}

When using fetchxml to query data, ensure you don't use self-closing tags. For example, instead of <attribute name="title"/>, use <attribute name="title"></attribute> with explicit closure tag </attribute>.

Results attribute

Results attribute in provided variable (such as 'resultVariable' in above sample) holds FetchXML query results and a few other attributes.

  • Entities

    This attribute contains the result of fetchxml query. You can iterate the result and use it in your web template.

    <table> 
    {% for entityVariable in resultVariable.results.entities %} 
    <tr> 
    <td>Attribut-1: {{ entityVariable.attribute1 }}</td> 
    <td>Attribut-2: {{ entityVariable.attribute2 }}</td> 
    </tr> 
    {% endfor %} 
    </table> 
    
  • TableName

    Gets the logical name of the entity.

  • ExtensionData

    Gets the structure that contains extra data.

  • MinActiveRowVersion

    Gets the lowest active row version value.

  • MoreRecords

    Gets whether there are more records available.

  • PagingCookie

    Gets the current paging information.

  • TotalRecordCount

    Gets the total number of records in the collection.
    ReturnTotalRecordCount was true when the query was executed.

  • TotalRecordCountLimitExceeded

    Gets whether the results of the query exceed the total record count.

XML attribute

XML attribute in provided variable (such as 'resultVariable' in above sample) holds the resultant query that can be used to get data from Microsoft Dataverse. This attribute is useful for debugging purpose when you want to understand how table permission is getting applied on this fetchxml tag.

Other supported elements and attributes

fetchxml liquid tag supports the following attributes, and child elements.

Element/Child element Attributes Child element
fetch mapping
version
count
page
paging-cookie
utc-offset
aggregate
distinct
min-active-row-version
output-format
returntotalrecordcount
no-lock
order
entity
order attribute
alias
descending
entity name
all-attributes
no-attrs
attribute
order
filter
link-entity
filter type
hint
isquickfindfields
condition
filter
link-entity name
from
to
alias
link-type
visible
intersect
all-attributes
no-attrs
attribute
order
filter
link-entity
condition column
entityname
attribute
operator
aggregate
alias
uiname
uitype
uihidden
value
value

include

Includes the contents of one template in another, by name. In Power Pages, the source of this other template will generally be a web template. This operator allows for the reuse of common template fragments in multiple places.

When a template is included in another, the included template will have access to any variables defined in the parent template.

{% include 'My Template' %}

It's also possible to pass any number of named parameters to the include tag. These parameters will then be defined as variables in the included template.

{% include 'My Template' a:x, b:y %}

block

Used with extends to provide template inheritance. See extends for usage.

extends

Used with the block tag, provides template inheritance. This operator allows multiple templates to use a shared layout, while overriding specific areas of the parent layout.

In Power Pages, the parent template name provided to the tag will generally refer to the name of a web template.

When extends is used, it must be the first content in the template, and can only be followed by one or more block tags.

If a block defined in the parent template isn't overridden, its contents in the parent template (if any) will be rendered.

comment

Allows you to leave unrendered code inside a Liquid template. Any content within the block won't be rendered, and any Liquid code within won't be executed.

Code

Hello{% comment %}, {{ user.fullname }}{% endcomment %}. My name is Charles.

Output

Hello. My name is Charles.

raw

Allows output of Liquid code on a page without having it parsed and executed.

Output

Hello, {{ user.fullname }}. My name is Charles.

substitution

When you enable the header and footer caching, and want to avoid caching of certain section output, you can use this tag. This tag provides the content block in header or footer where output of the wrapped content block doesn't get cached. This operator is helpful in the scenarios where user is using an object that can frequently get updated, such as request, page, language, and date. For example, refer to the header and footer web template source code update scenarios when header and footer caching is enabled.

Tip

The URL used in request.url can be any requested value, and gets cached for subsequent requests. To ensure correct value in request.url, consider using substitution tag, partial URL such as ~{WebFile path} or storing the portal URL in Site Settings.

codecomponent

See Understand codecomponent Dataverse entity tag, Use code components Liquid template tag.

See also

Control flow tags
Iteration tags
Variable tags
Dataverse Liquid tags
Use code components Liquid template tag