Merge pull request #588 from queenstdev/master

fix #587 Render true and false Mustache tags
This commit is contained in:
Igor Mróz 2023-02-03 21:34:54 +01:00 committed by GitHub
commit 4eea4eb4c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -233,6 +233,8 @@ namespace crow
auto& ctx = optional_ctx.second;
switch (ctx.t())
{
case json::type::False:
case json::type::True:
case json::type::Number:
out += ctx.dump();
break;

View File

@ -1243,6 +1243,24 @@ TEST_CASE("template_basic")
CHECK("attack of killer tomatoes" == result);
} // template_basic
TEST_CASE("template_true_tag")
{
auto t = crow::mustache::compile(R"---({{true_value}})---");
crow::mustache::context ctx;
ctx["true_value"] = true;
auto result = t.render_string(ctx);
CHECK("true" == result);
} // template_true_tag
TEST_CASE("template_false_tag")
{
auto t = crow::mustache::compile(R"---({{false_value}})---");
crow::mustache::context ctx;
ctx["false_value"] = false;d
auto result = t.render_string(ctx);
CHECK("false" == result);
} // template_false_tag
TEST_CASE("template_function")
{
auto t = crow::mustache::compile("attack of {{func}}");