mirror of
https://github.com/pantor/inja.git
synced 2026-05-01 19:42:28 +00:00
Fix line statements
This commit is contained in:
+1
-1
@@ -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
@@ -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) {
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user