fix #587 Render true and false Mustache tags

This commit is contained in:
queenstdev 2023-01-24 11:15:06 -05:00 committed by Igor Mróz
parent 5927b958de
commit b493cd646e
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}}");