TemplatePage: Change 'content' to shared_ptr
This commit is contained in:
parent
92be470545
commit
c9dc3416d7
@ -27,7 +27,7 @@ TemplatePage::TemplatePage()
|
|||||||
|
|
||||||
TemplatePage::TemplatePage(std::string content)
|
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)
|
void TemplatePage::setVar(const std::string &key, std::string value)
|
||||||
@ -40,5 +40,5 @@ std::string TemplatePage::render() const
|
|||||||
Varreplacer replacer("{qswiki:");
|
Varreplacer replacer("{qswiki:");
|
||||||
replacer.addResolver("var",
|
replacer.addResolver("var",
|
||||||
[&](std::string_view key) { return utils::getKeyOrEmpty(this->varsMap, std::string(key)); });
|
[&](std::string_view key) { return utils::getKeyOrEmpty(this->varsMap, std::string(key)); });
|
||||||
return replacer.parse(this->content);
|
return replacer.parse(*this->content);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
class TemplatePage
|
class TemplatePage
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string content;
|
std::shared_ptr<const std::string> content;
|
||||||
std::map<std::string, std::string> varsMap;
|
std::map<std::string, std::string> varsMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user