Skip to content

Commit 3d79ece

Browse files
committed
docs: add note about the use of Bindings in templates
1 parent d782d23 commit 3d79ece

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,18 @@ and the second a metadata called `snapshot` (see next)
9393

9494
The line `1` will evaluate the bindings `title` and `who`, but the line `2`
9595
will only eval the `who` variable, because it uses the snapshot of the previous
96-
render. It only eval the changes and does not need to compile the binary again,
96+
render. It only eval the changes and does not need to compile the binary again, unless the expression contains the global `Bindings` variable (see below),
9797
because the `snapshot` includes the required information.
9898

99+
The global `Bindings` variable can be used to get values in a conditional way, checking if the variable exists in the template, e.g.:
100+
101+
```
102+
<%= maps:get(foo, Bindings, bar) .%>
103+
```
104+
105+
Including `Bindings` to the expression makes it to be always evaluated by the render function.
106+
107+
99108
Including the header
100109

101110
```erlang

0 commit comments

Comments
 (0)