diff --git a/include/inja/config.hpp b/include/inja/config.hpp index de9a4ff..0d571b0 100644 --- a/include/inja/config.hpp +++ b/include/inja/config.hpp @@ -25,7 +25,10 @@ struct LexerConfig { std::string open_chars {"#{"}; void update_open_chars() { - open_chars = "\n"; + open_chars = ""; + if (open_chars.find(line_statement[0]) == std::string::npos) { + open_chars += line_statement[0]; + } if (open_chars.find(statement_open[0]) == std::string::npos) { open_chars += statement_open[0]; } diff --git a/single_include/inja/inja.hpp b/single_include/inja/inja.hpp index 11c4877..c6edbb4 100644 --- a/single_include/inja/inja.hpp +++ b/single_include/inja/inja.hpp @@ -1371,7 +1371,10 @@ struct LexerConfig { std::string open_chars {"#{"}; void update_open_chars() { - open_chars = "\n"; + open_chars = ""; + if (open_chars.find(line_statement[0]) == std::string::npos) { + open_chars += line_statement[0]; + } if (open_chars.find(statement_open[0]) == std::string::npos) { open_chars += statement_open[0]; } diff --git a/test/unit-renderer.cpp b/test/unit-renderer.cpp index 41d55d8..dfc6e71 100644 --- a/test/unit-renderer.cpp +++ b/test/unit-renderer.cpp @@ -388,4 +388,17 @@ TEST_CASE("other-syntax") { CHECK( env.render("Hello {# Test #}", data) == "Hello {# Test #}" ); CHECK( env.render("Hello (& Test &)", data) == "Hello " ); } + + SECTION("multiple changes") { + inja::Environment env; + env.set_line_statement("$$"); + env.set_expression("<%", "%>"); + + std::string string_template = R"DELIM(Hello <%name%> +$$ if name == "Peter" + You really are <%name%> +$$ endif +)DELIM"; + CHECK( env.render(string_template, data) == "Hello Peter\n You really are Peter\n"); + } }