Skip to main content

What theme templates can use

Templates run in a restricted version of Twig. They can use the features in this topic and nothing else. Using anything else is an error when the theme is checked, even in a part of a template that never runs.

Tags: if, for, set, block, extends, use, include, embed, apply, macro, import, from

Filters: escape, e, upper, lower, capitalize, trim, date, length, slice, join, split, default, merge, sort, first, last, map, filter, keys, json_encode, number_format, replace, striptags, url_encode, excerpt, content_sections

Functions: asset, include, min, max, parent, block, paligo_search_box, paligo_search_results, paligo_breadcrumbs, paligo_toc, paligo_pager, paligo_language_switcher, paligo_contrast_color, related_pages

Tests: all of Twig's tests except constant, such as defined, empty, null, iterable, even, odd, same as and divisible by

Not available, among others:

  • The raw filter. The HTML that Paligo provides already prints as HTML.

  • range() and the .. operator. Loop over a list instead.

  • attribute(). Use brackets, such as item[key].

  • template_from_string(), constant(), random(), cycle(), dump() and source().

  • The with, autoescape, do, spaceless and sandbox tags.

  • Calling methods or reading properties of objects. Every value in a template is a text, number, list or map.

For how Twig works, see the Twig documentation.