diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d90dc..a1a64a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ endif() ## PROJECT ## name and version ## -project(inja LANGUAGES CXX VERSION 1.0.0) +project(inja LANGUAGES CXX VERSION 1.0.1) set(INJA_VERSION ${PROJECT_VERSION}) ## diff --git a/src/inja.hpp b/src/inja.hpp index 1ea870c..f94dca1 100644 --- a/src/inja.hpp +++ b/src/inja.hpp @@ -30,7 +30,7 @@ SOFTWARE. #define PANTOR_INJA_VERSION_MAJOR 1 #define PANTOR_INJA_VERSION_MINOR 0 -#define PANTOR_INJA_VERSION_PATCH 0 +#define PANTOR_INJA_VERSION_PATCH 1 #ifndef NLOHMANN_JSON_HPP @@ -630,7 +630,7 @@ public: std::map regex_map_delimiters = { {Parsed::Delimiter::Statement, Regex{"\\{\\%\\s*(.+?)\\s*\\%\\}"}}, - {Parsed::Delimiter::LineStatement, Regex{"(?:^|\\n)##\\s*(.+)\\s*"}}, + {Parsed::Delimiter::LineStatement, Regex{"(?:^|\\n)## *(.+?) *(?:\\n|$)"}}, {Parsed::Delimiter::Expression, Regex{"\\{\\{\\s*(.+?)\\s*\\}\\}"}}, {Parsed::Delimiter::Comment, Regex{"\\{#\\s*(.*?)\\s*#\\}"}} }; @@ -925,7 +925,7 @@ public: } void set_line_statement(const std::string& open) { - parser.regex_map_delimiters[Parsed::Delimiter::LineStatement] = Regex{"(?:^|\\n)" + open + "\\s*(.+)\\s*"}; + parser.regex_map_delimiters[Parsed::Delimiter::LineStatement] = Regex{"(?:^|\\n)" + open + " *(.+?) *(?:\\n|$)"}; } void set_expression(const std::string& open, const std::string& close) { diff --git a/test/src/unit-renderer.cpp b/test/src/unit-renderer.cpp index 03e8f52..41098c4 100644 --- a/test/src/unit-renderer.cpp +++ b/test/src/unit-renderer.cpp @@ -82,6 +82,18 @@ TEST_CASE("types") { CHECK_THROWS_WITH( env.render("{% if is_happy %}{% if is_happy %}{% endif %}", data), "[inja.exception.parser_error] misordered if statement" ); CHECK_THROWS_WITH( env.render("{% if is_happy %}{% else if is_happy %}{% end if %}", data), "[inja.exception.parser_error] misordered if statement" ); } + + SECTION("line statements") { + CHECK( env.render(R"(## if is_happy +Yeah! +## endif)", data) == "Yeah!" ); + + CHECK( env.render(R"(## if is_happy +## if is_happy +Yeah! +## endif +## endif )", data) == "Yeah!" ); + } } TEST_CASE("functions") {