Add support for setting subobjects via JSON pointer in set statements. (#202)

E.g. `{% set x.y = 1 %}` sets the `y` member of `x` to 1.
This commit is contained in:
Bryce Adelstein Lelbach aka wash
2021-06-09 12:39:16 -07:00
committed by GitHub
parent 86f38f05d7
commit 798a0b92b1
5 changed files with 48 additions and 8 deletions

View File

@@ -198,6 +198,13 @@ Variables can also be defined within the template using the set statment.
render("{% set new_hour=23 %}{{ new_hour }}pm", data); // "23pm"
```
json pointers can be used to set sub-objects:
```.cpp
render("{% set time.start=18 %}{{ time.start }}pm", data); // "18pm"
```
Assignments only set the value within the rendering context; they do not modify the json object passed into the `render` call.
### Functions
A few functions are implemented within the inja template syntax. They can be called with