Docs & changelog entry

This commit is contained in:
David Jennes
2022-07-28 02:30:25 +02:00
parent 07d36651bf
commit 5f0c01809d
2 changed files with 11 additions and 1 deletions

View File

@@ -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

View File

@@ -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
~~~~~~~ ~~~~~~~