#pragma once // Jinja-like template environment: extends plus blocks, includes, if, for, // filters, autoescape for .html/.htm/.xml with explicit safe opt-out. // Gap: real molo::templates in 05-request-routing.md owns the full lexer, // parser, sandbox, and streamed rendering. #include #include #include #include namespace molo::example::fw { using TemplateList = std::vector>; using TemplateValue = std::variant; using TemplateCtx = std::map; class Environment { public: void add_template(std::string name, std::string source); void add_global(std::string key, std::string value); bool has_template(const std::string& name) const; std::string render(const std::string& name, TemplateCtx ctx) const; private: std::string render_source(const std::string& name, const std::string& src, TemplateCtx& ctx, int depth) const; std::string render_blocks(const std::string& src, TemplateCtx& ctx, int depth) const; std::map templates_; std::map globals_; }; std::string html_escape(std::string_view in); } // namespace molo::example::fw