took repeated code out of the if else statement

This commit is contained in:
Farook Al-Sammarraie 2021-12-17 09:07:46 +03:00 committed by GitHub
parent 5c806252f0
commit cca1d54ce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -222,26 +222,18 @@ namespace crow
out += ctx.s; out += ctx.s;
break; break;
case json::type::Function: case json::type::Function:
std::string execute_result = ctx.execute();
while (execute_result.find("{{") != std::string::npos)
{
template_t result_plug(execute_result);
execute_result = result_plug.render(*(stack[0]));
}
if (action.t == ActionType::Tag) if (action.t == ActionType::Tag)
{
std::string execute_result = ctx.execute();
while (execute_result.find("{{") != std::string::npos)
{
template_t result_plug(execute_result);
execute_result = result_plug.render(*(stack[0]));
}
escape(execute_result, out); escape(execute_result, out);
}
else else
{
std::string execute_result = ctx.execute();
while (execute_result.find("{{") != std::string::npos)
{
template_t result_plug(execute_result);
execute_result = result_plug.render(*(stack[0]));
}
out += execute_result; out += execute_result;
}
break; break;
default: default:
throw std::runtime_error("not implemented tag type" + boost::lexical_cast<std::string>(static_cast<int>(ctx.t()))); throw std::runtime_error("not implemented tag type" + boost::lexical_cast<std::string>(static_cast<int>(ctx.t())));