I have a twig template where I would like to test if an item begins with a certain value
{% if item.ContentTypeId == \'0x0120\' %}
-
Yes, Twig supports regular expressions in comparisons: http://twig.sensiolabs.org/doc/templates.html#comparisons
In your case it would be:
{% if item.ContentTypeId matches '/^0x0120.*/' %}
...
{% else %}
...
{% endif %}
- 热议问题