aboutsummaryrefslogtreecommitdiff
path: root/lib/mstch/src/mstch.cpp
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-01-16 15:43:04 +0800
committerMistivia <i@mistivia.com>2025-01-16 15:53:58 +0800
commit8689a7c78c50676ea739f52fbcee9f091709f5c0 (patch)
treebbb72c68e5e1753f751133941a402caa43e29a16 /lib/mstch/src/mstch.cpp
parent00afb767ae37488d99f78363d031b898b1932354 (diff)
add mstch
Diffstat (limited to 'lib/mstch/src/mstch.cpp')
-rw-r--r--lib/mstch/src/mstch.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/mstch/src/mstch.cpp b/lib/mstch/src/mstch.cpp
new file mode 100644
index 0000000..4d84e97
--- /dev/null
+++ b/lib/mstch/src/mstch.cpp
@@ -0,0 +1,20 @@
+#include <iostream>
+
+#include "mstch/mstch.hpp"
+#include "render_context.hpp"
+
+using namespace mstch;
+
+std::function<std::string(const std::string&)> mstch::config::escape;
+
+std::string mstch::render(
+ const std::string& tmplt,
+ const node& root,
+ const std::map<std::string,std::string>& partials)
+{
+ std::map<std::string, template_type> partial_templates;
+ for (auto& partial: partials)
+ partial_templates.insert({partial.first, {partial.second}});
+
+ return render_context(root, partial_templates).render(tmplt);
+}