mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 12:37:15 +00:00
minor #2536 show how to use a variable as hash map key (tolry)
This PR was submitted for the 2.x branch but it was squashed and merged into the 1.x branch instead (closes #2536).
Discussion
----------
show how to use a variable as hash map key
currently the documentation does not explain how it's possible to use a variable as key in a hash map
Commits
-------
ef6c9505 show how to use a variable as hash map key
This commit is contained in:
+2
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user