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 29, 2022
1 parent 07d3665 commit 5f0c018
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
[David Jennes](https://github.com/djbe)
[#164](https://github.com/stencilproject/Stencil/pull/164)
[#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

Expand Down
9 changes: 8 additions & 1 deletion 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())
]
Boolean expressions
-------------------

Expand All @@ -60,7 +68,6 @@ For example, this will output string `true` if variable is equal to 1 and `false

{{ variable == 1 }}


Filters
~~~~~~~

Expand Down

0 comments on commit 5f0c018

Please sign in to comment.