diff --git a/src/compiler/TemplatingEngine.h b/src/compiler/TemplatingEngine.h index 474afd5..548da3f 100644 --- a/src/compiler/TemplatingEngine.h +++ b/src/compiler/TemplatingEngine.h @@ -189,8 +189,13 @@ public: onTextBodyFinished(); } - void onTextBodyFinished() + void onTextBodyFinished(std::string working_string = {}) { + if (!working_string.empty()) + { + mWorkingTextBody->addLine(working_string); + } + if (mWorkingTextBody->hasContent()) { mWorkingNode->addChild(std::move(mWorkingTextBody)); @@ -206,6 +211,7 @@ public: bool in_statement{ false }; bool in_expression{ false }; std::string working_string; + std::string last_working_string; for (auto c : line) { if (c == '{') @@ -225,6 +231,7 @@ public: { last_was_ldelimiter = false; in_statement = true; + last_working_string = working_string; working_string = ""; } else if (c == '%' && in_statement) @@ -235,7 +242,7 @@ public: { if (last_was_statement_rdelimiter) { - onTextBodyFinished(); + onTextBodyFinished(last_working_string); onFoundStatement(working_string); last_was_statement_rdelimiter = false; working_string = ""; @@ -253,6 +260,12 @@ public: working_string = ""; } } + else if (last_was_ldelimiter && (!in_statement && !in_expression)) + { + last_was_ldelimiter = false; + working_string += '{'; + working_string += c; + } else { working_string += c; @@ -267,7 +280,6 @@ public: void onFoundStatement(const std::string& statement_string) { - std::cout << "Got Statement: " << statement_string << std::endl; const auto statement_elements = StringUtils::split(statement_string); if (statement_elements.size() == 0) @@ -283,6 +295,10 @@ public: { onFoundEndBlock(statement_elements); } + else if (statement_type == "extends") + { + onFoundExtends(statement_elements); + } } diff --git a/test/compiler/TestTemplatingEngine.cpp b/test/compiler/TestTemplatingEngine.cpp index cd85e4a..ee62273 100644 --- a/test/compiler/TestTemplatingEngine.cpp +++ b/test/compiler/TestTemplatingEngine.cpp @@ -10,6 +10,7 @@ int main() auto engine = TemplatingEngine(data_loc); engine.loadTemplateFiles(); engine.processTemplate("index"); + engine.processTemplate("base"); } \ No newline at end of file