From ef6c950505956ebc3a99ab2cecd7b3ebcbb0feb2 Mon Sep 17 00:00:00 2001 From: Tobias Olry Date: Sat, 29 Jul 2017 20:25:20 +0200 Subject: [PATCH] show how to use a variable as hash map key --- doc/templates.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/templates.rst b/doc/templates.rst index d4dbe32d6..3d60779a0 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -611,7 +611,8 @@ exist: { 2: 'foo', 4: 'bar' } {# keys as expressions (the expression must be enclosed into parentheses) -- as of Twig 1.5 #} - { (1 + 1): 'foo', (a ~ 'b'): 'bar' } + {% set foo = 'foo' %} + { (foo): 'foo', (1 + 1): 'bar', (foo ~ 'b'): 'baz' } * ``true`` / ``false``: ``true`` represents the true value, ``false`` represents the false value.