diff --git a/include/inja/renderer.hpp b/include/inja/renderer.hpp index b28340bc..f1281711 100644 --- a/include/inja/renderer.hpp +++ b/include/inja/renderer.hpp @@ -57,7 +57,11 @@ class Renderer : public NodeVisitor { if (value->is_string()) { std::string val; if (config.escape_strings) { + // get the value as a dump() to properly escape values val = value->dump(); + + // strip the leading and trailing " characters that are added by dump() + // if C++20 is adopted, val.starts_with and val.ends_with would clean this up a bit val = val.substr(0,1) == "\"" && val.substr(val.length()-1,1) == "\"" ? val.substr(1, val.length()-2) : val;