Twig Tests
On this page
Herbie is using Twig Tests for evaluating boolean conditions in layout and content files. In addition to the built-in tests of Twig, the following tests are available.
file_readable
Tests if the given alias or path exists and is readable.
Parameter | Type | Description | Default |
[return] | bool |
Example:
{% if "@site/data" is file_readable %}
Path or file is readable
{% endif %}
file_writable
Tests if the given alias or path exists and is writable.
Parameter | Type | Description | Default |
[return] | bool |
Example:
{% if "@site/data" is file_writable %}
Path or file is writable
{% endif %}
Built-in Tests
In addition to the tests mentioned above, Twig's built-in tests are of course also available. Please note that some of the tests may require the installation of additional Composer packages.