TemplatePage: Change 'content' to shared_ptr

This commit is contained in:
Albert S. 2021-10-10 22:32:13 +02:00
parent 92be470545
commit c9dc3416d7
2 changed files with 4 additions and 3 deletions

View File

@ -27,7 +27,7 @@ TemplatePage::TemplatePage()
TemplatePage::TemplatePage(std::string content)
{
this->content = content;
this->content = std::make_shared<std::string>(content);
}
void TemplatePage::setVar(const std::string &key, std::string value)
@ -40,5 +40,5 @@ std::string TemplatePage::render() const
Varreplacer replacer("{qswiki:");
replacer.addResolver("var",
[&](std::string_view key) { return utils::getKeyOrEmpty(this->varsMap, std::string(key)); });
return replacer.parse(this->content);
return replacer.parse(*this->content);
}

View File

@ -3,10 +3,11 @@
#include <string>
#include <string_view>
#include <map>
#include <memory>
class TemplatePage
{
private:
std::string content;
std::shared_ptr<const std::string> content;
std::map<std::string, std::string> varsMap;
public: