Skip to content

Commit

Permalink
Docs & changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Jul 28, 2022
1 parent a73a874 commit 0e254e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
- You can now access outer loop's scope by labeling it: `{% outer: for ... %}... {% for ... %} {{ outer.counter }} {% endfor %}{% endfor %}`.
[Ilya Puchka](https://github.com/ilyapuchka)
[#175](https://github.com/stencilproject/Stencil/pull/175)
- 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

Expand Down
8 changes: 8 additions & 0 deletions docs/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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())
]
Filters
~~~~~~~

Expand Down

0 comments on commit 0e254e1

Please sign in to comment.