partials documentation
This commit is contained in:
parent
a478af2a27
commit
a8afdcef90
1 changed files with 24 additions and 1 deletions
25
README.md
25
README.md
|
@ -73,7 +73,30 @@ if your compiler supports it.
|
||||||
|
|
||||||
### Partials
|
### Partials
|
||||||
|
|
||||||
TODO
|
Partials can be passed in a `std::map` as the third parameter of the
|
||||||
|
`mstch::render` function:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
std::string view{"{{#names}}{{> user}}{{/names}}"};
|
||||||
|
std::string user_view{"<strong>{{name}}\n</strong>"};
|
||||||
|
mstch::map context{
|
||||||
|
{"names", mstch::array{
|
||||||
|
mstch::map{{"name", std::string{"Chris"}}},
|
||||||
|
mstch::map{{"name", std::string{"Mark"}}},
|
||||||
|
mstch::map{{"name", std::string{"Scott"}}},
|
||||||
|
}}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::cout << mstch::render(view, context, {{"user", user_view}}) << std::endl;
|
||||||
|
```
|
||||||
|
|
||||||
|
The output will be:
|
||||||
|
|
||||||
|
```
|
||||||
|
<strong>Chris</strong>
|
||||||
|
<strong>Mark</strong>
|
||||||
|
<strong>Scott</strong>
|
||||||
|
```
|
||||||
|
|
||||||
### Lambdas
|
### Lambdas
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue