Docs & changelog entry
This commit is contained in:
@@ -41,6 +41,9 @@
|
|||||||
[David Jennes](https://github.com/djbe)
|
[David Jennes](https://github.com/djbe)
|
||||||
[#164](https://github.com/stencilproject/Stencil/pull/164)
|
[#164](https://github.com/stencilproject/Stencil/pull/164)
|
||||||
[#325](https://github.com/stencilproject/Stencil/pull/325)
|
[#325](https://github.com/stencilproject/Stencil/pull/325)
|
||||||
|
- Allow providing lazily evaluated context data, using the `LazyValueWrapper` structure.
|
||||||
|
[David Jennes](https://github.com/djbe)
|
||||||
|
[#324](https://github.com/stencilproject/Stencil/pull/324)
|
||||||
|
|
||||||
### Deprecations
|
### Deprecations
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ For example, if you have the following context:
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
You can use the `LazyValueWrapper` type to have values in your context that will be lazily evaluated. The provided value will only be evaluated when it's first accessed in your template, and will be cached afterwards. For example:
|
||||||
|
|
||||||
|
.. code-block:: swift
|
||||||
|
|
||||||
|
[
|
||||||
|
"magic": LazyValueWrapper(myHeavyCalculations())
|
||||||
|
]
|
||||||
|
|
||||||
Boolean expressions
|
Boolean expressions
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
@@ -60,7 +68,6 @@ For example, this will output string `true` if variable is equal to 1 and `false
|
|||||||
|
|
||||||
{{ variable == 1 }}
|
{{ variable == 1 }}
|
||||||
|
|
||||||
|
|
||||||
Filters
|
Filters
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user