From 84faa3a31d98e1b9d1b1307aed0fde4c7648f594 Mon Sep 17 00:00:00 2001 From: pantor Date: Sun, 11 Nov 2018 14:09:55 +0100 Subject: [PATCH] allow more flexible whitespaces --- src/inja.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/inja.hpp b/src/inja.hpp index 2e92de6..b2ff1db 100644 --- a/src/inja.hpp +++ b/src/inja.hpp @@ -649,9 +649,9 @@ public: }; const std::map regex_map_statement_openers = { - {Parsed::Statement::Loop, Regex{"for (.+)"}}, - {Parsed::Statement::Condition, Regex{"if (.+)"}}, - {Parsed::Statement::Include, Regex{"include \"(.+)\""}} + {Parsed::Statement::Loop, Regex{"for\\s+(.+)"}}, + {Parsed::Statement::Condition, Regex{"if\\s+(.+)"}}, + {Parsed::Statement::Include, Regex{"include\\s+\"(.+)\""}} }; const std::map regex_map_statement_closers = { @@ -660,13 +660,13 @@ public: }; const std::map regex_map_loop = { - {Parsed::Loop::ForListIn, Regex{"for (\\w+) in (.+)"}}, - {Parsed::Loop::ForMapIn, Regex{"for (\\w+), (\\w+) in (.+)"}}, + {Parsed::Loop::ForListIn, Regex{"for\\s+(\\w+)\\s+in\\s+(.+)"}}, + {Parsed::Loop::ForMapIn, Regex{"for\\s+(\\w+),\\s+(\\w+)\\s+in\\s+(.+)"}}, }; const std::map regex_map_condition = { - {Parsed::Condition::If, Regex{"if (.+)"}}, - {Parsed::Condition::ElseIf, Regex{"else if (.+)"}}, + {Parsed::Condition::If, Regex{"if\\s+(.+)"}}, + {Parsed::Condition::ElseIf, Regex{"else\\s+if\\s+(.+)"}}, {Parsed::Condition::Else, Regex{"else"}} };