aboutsummaryrefslogtreecommitdiff
path: root/MemDriverWeb/minitmpl.cpp
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2019-07-04 00:03:51 +0200
committerToni Uhlig <matzeton@googlemail.com>2019-07-04 00:03:51 +0200
commit1890024e57f623ceec744bb3a6922d89d2d47640 (patch)
tree736b4cd28fb14fce546acbc93b2499f3c34586e3 /MemDriverWeb/minitmpl.cpp
parentcaf93747fb255f7e5750618216c560440d3fa42f (diff)
very basic templating engine
Diffstat (limited to 'MemDriverWeb/minitmpl.cpp')
-rw-r--r--MemDriverWeb/minitmpl.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/MemDriverWeb/minitmpl.cpp b/MemDriverWeb/minitmpl.cpp
new file mode 100644
index 0000000..3d7c34c
--- /dev/null
+++ b/MemDriverWeb/minitmpl.cpp
@@ -0,0 +1,19 @@
+#include "pch.h"
+#include "minitmpl.h"
+
+std::map<std::string, template_cb> TemplateString::template_callbacks;
+
+std::string TemplateString::doTemplateStr() {
+ size_t pos = 0;
+ in_cache = str();
+
+ out_cache.clear();
+ for (auto& key : template_callbacks) {
+ while ((pos = in_cache.find(key.first, pos)) != std::string::npos) {
+ in_cache.replace(pos, key.first.length(), key.second(out_cache));
+ pos += out_cache.length();
+ }
+ }
+
+ return in_cache;
+} \ No newline at end of file