#pragma once #include #include #include #include #include #include "state/render_state.hpp" #include "template_type.hpp" #include namespace mstch { class render_context { public: class push { public: push(render_context &context, const mstch::node &node = {}); ~push(); std::string render(const template_type &templt); private: render_context &m_context; }; render_context(const mstch::node &node, const std::map &partials); const mstch::node &get_node(const std::string &token); std::string render(const template_type &templt, const std::string &prefix = ""); std::string render_partial(const std::string &partial_name, const std::string &prefix); template void set_state(Args &&... args) { m_state.top() = std::unique_ptr(new T(std::forward(args)...)); } private: static const mstch::node null_node; const mstch::node &find_node(const std::string &token, std::list current_nodes); std::map m_partials; std::deque m_nodes; std::list m_node_ptrs; std::stack> m_state; }; }