From 6bfec7e45f4f70b1c0508c179b2f1bcb159ec8d0 Mon Sep 17 00:00:00 2001 From: Jacob Bohanon Date: Wed, 19 Jul 2023 16:43:35 -0400 Subject: [PATCH] add comments --- include/inja/renderer.hpp | 4 ++++ 1 file changed, 4 insertions(+) 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;