From 42bd974715e20f014e20a6faf4cbf23b366d71c2 Mon Sep 17 00:00:00 2001 From: stellarpower Date: Sat, 9 Dec 2023 16:29:55 +0000 Subject: [PATCH 1/2] Add Object example to Readme --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ea3f41..4735531 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,23 @@ tmpl.render({"employees", employees}, std::cout); // Steve, Bill, ```` -### Example 3 - Custom Render Handler + +### Example 3 - Objects + +````cpp +mustache tmpl("{{greeting}}, {{name}}!"); + +basic_object data; +// `basic_object` is an `unordered_map`. +data["greeting"] = "Hello"; +data["name" ] = "Jane"; + +std::string result = tmpl.render(data); +// result == "Hello, Jane!" +```` + + +### Example 4 - Custom Render Handler ````cpp mustache tmpl("Hello {{what}}!"); @@ -40,6 +56,9 @@ tmpl.render({"what", "World"}, [&ss](const std::string& str) { }); // ss.str() == "Hello World!" ```` +### + + ## Supported Features From 3207e4fbdc7461247bf5f61fc9e8cc24e4ee7e22 Mon Sep 17 00:00:00 2001 From: stellarpower Date: Sat, 9 Dec 2023 16:31:14 +0000 Subject: [PATCH 2/2] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4735531..782110e 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ tmpl.render({"what", "World"}, [&ss](const std::string& str) { }); // ss.str() == "Hello World!" ```` -### +