diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2019-07-03 17:52:43 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2019-07-03 17:52:43 +0200 |
commit | caf93747fb255f7e5750618216c560440d3fa42f (patch) | |
tree | abf6e3358a0951e75396502bc67562fe870c98af /MemDriverWeb/minitmpl.h | |
parent | 249e58d81708ff9d486a5ee8fdc80bd208a78b53 (diff) |
simple string based templating engine preps
Diffstat (limited to 'MemDriverWeb/minitmpl.h')
-rw-r--r-- | MemDriverWeb/minitmpl.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/MemDriverWeb/minitmpl.h b/MemDriverWeb/minitmpl.h new file mode 100644 index 0000000..446930a --- /dev/null +++ b/MemDriverWeb/minitmpl.h @@ -0,0 +1,17 @@ +#pragma once + +#include <sstream> + +class TemplateString : public std::stringstream +{ +public: + std::string& doTemplateStr(const std::string& search, const std::string& replace) { + size_t pos = 0; + std::string s = this->str(); + while ((pos = s.find(search, pos)) != std::string::npos) { + s.replace(pos, search.length(), replace); + pos += replace.length(); + } + return s; + } +};
\ No newline at end of file |