Subscript syntax for Variables (#215)

* Implement variable indirect resolution

* Add some tests

* Changelog entry

* Update documentation

* Rework the syntax to use brackets instead of a $

* Move the lookup parser into it's own file

* Add invalid syntax tests

* Swift 3 support

* Rename some things + extra test
This commit is contained in:
David Jennes
2018-05-19 22:03:51 +02:00
committed by Ilya Puchka
parent 39ed9aa753
commit 2e18892f4c
5 changed files with 234 additions and 6 deletions

View File

@@ -31,6 +31,24 @@ For example, if `people` was an array:
There are {{ people.count }} people. {{ people.first }} is the first
person, followed by {{ people.1 }}.
You can also use the subscript operator for indirect evaluation. The expression
between brackets will be evaluated first, before the actual lookup will happen.
For example, if you have the following context:
.. code-block:: swift
[
"item": [
"name": "John"
],
"key": "name"
]
.. code-block:: html+django
The result of {{ item[key] }} will be the same as {{ item.name }}. It will first evaluate the result of {{ key }}, and only then evaluate the lookup expression.
Filters
~~~~~~~