From a8afdcef900522495a345e1ad0a400bc91aa17ec Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Fri, 24 Apr 2015 15:20:49 +0200 Subject: [PATCH] partials documentation --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f68f47..33f9f63 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,30 @@ if your compiler supports it. ### 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{"{{name}}\n"}; +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: + +``` +Chris +Mark +Scott +``` ### Lambdas