From e1178abfa18bd95fd358a01bc293c33d8b812335 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Jun 2026 21:58:29 +0200 Subject: [PATCH] Document storing an enum in a variable to avoid repeating its FQCN --- doc/functions/enum.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/functions/enum.rst b/doc/functions/enum.rst index 6fb9bb009..23d5f0c3c 100644 --- a/doc/functions/enum.rst +++ b/doc/functions/enum.rst @@ -32,6 +32,15 @@ When using a string literal for the ``enum`` argument, it will be validated during compile time to be a valid enum name. +As the FQCN can be long, you can store the enum in a variable to avoid repeating +it: + +.. code-block:: twig + + {% set suite = enum('App\\CardSuite') %} + {{ suite.Clubs.value }} {# "clubs" #} + {{ suite.Spades.value }} {# "spades" #} + Arguments ---------