mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
b03de9de05
* 3.x: Update CHANGELOG Fix accessing arrays with stringable objects as key Update inky_to_html.rst: Updating link Update replace.rst [Doc] Tweaks in the escaping article Compile 'index' with repr (not string) in EmbedNode Introduce registerUndefinedTestCallback Fix intl test Bump minimum Commonmark requirement Support two words test guard Bump version Improve documentation examples for `enum` and `enum_cases` Avoid errors when failing to guess the template info for an error Add note to format_datetime explaining how to install required extensions Fix compatibility layer
19 lines
433 B
ReStructuredText
19 lines
433 B
ReStructuredText
``enum_cases``
|
|
==============
|
|
|
|
``enum_cases`` returns the list of cases for a given enum:
|
|
|
|
.. code-block:: twig
|
|
|
|
{% for case in enum_cases('App\\CardSuite') %}
|
|
{{ case.value }}
|
|
{% endfor %}
|
|
{# "clubs", "spades", "hearts", "diamonds" #}
|
|
|
|
When using a string literal for the ``enum`` argument, it will be validated during compile time to be a valid enum name.
|
|
|
|
Arguments
|
|
---------
|
|
|
|
* ``enum``: The FQCN of the enum
|