Fix line statements

This commit is contained in:
pantor
2018-03-19 12:20:12 +01:00
parent 561f8cf59e
commit e38df0931f
3 changed files with 16 additions and 4 deletions
+1 -1
View File
@@ -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})
##
+3 -3
View File
@@ -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<Parsed::Delimiter, Regex> 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) {
+12
View File
@@ -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") {