Template: Use MapCache, getPage(): Return value, not reference

This commit is contained in:
2021-10-08 00:10:20 +02:00
parent e970ba1682
commit 8ffa64beea
3 ha cambiato i file con 22 aggiunte e 19 eliminazioni

Vedi File

@@ -8,16 +8,17 @@
#include "response.h"
#include "searchresult.h"
#include "revision.h"
#include "cache/mapcache.h"
class Template
{
private:
ConfigVariableResolver *configVarResolver;
ConfigUrls *configUrls;
MapCache<TemplatePage> *pageCache;
std::string templateprefix;
std::string templatepath;
std::map<std::string, TemplatePage> pagesMap;
std::string resolveIncludes(std::string_view content);
std::string getPartPath(std::string_view partname);
@@ -27,12 +28,9 @@ class Template
public:
Template(std::string templateprefix, std::string templatepath, ConfigUrls &configUrls,
ConfigVariableResolver &configVarsResolver);
/* TODO: returning this as a reference is by no means a risk free business,
because between requests, different vars can be set conditionally,
thus creating a mess
*/
TemplatePage &getPage(const std::string &pagename);
ConfigVariableResolver &configVarsResolver, MapCache<TemplatePage> &pageCache);
TemplatePage getPage(const std::string &pagename);
std::string renderSearch(const std::vector<std::string> &results,
std::function<std::string(std::string)> callback) const;