Skip to content

Commit 2807953

Browse files
authored
Merge pull request #325 from neumannt/const-render
fix const correctness in template_t
2 parents c5d4fe4 + 2a77083 commit 2807953

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

include/crow/mustache.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ namespace crow
6464
}
6565

6666
private:
67-
std::string tag_name(const Action& action)
67+
std::string tag_name(const Action& action) const
6868
{
6969
return body_.substr(action.start, action.end - action.start);
7070
}
71-
auto find_context(const std::string& name, const std::vector<context*>& stack, bool shouldUseOnlyFirstStackValue = false) -> std::pair<bool, context&>
71+
auto find_context(const std::string& name, const std::vector<context*>& stack, bool shouldUseOnlyFirstStackValue = false) const -> std::pair<bool, context&>
7272
{
7373
if (name == ".")
7474
{
@@ -133,7 +133,7 @@ namespace crow
133133
return {false, empty_str};
134134
}
135135

136-
void escape(const std::string& in, std::string& out)
136+
void escape(const std::string& in, std::string& out) const
137137
{
138138
out.reserve(out.size() + in.size());
139139
for (auto it = in.begin(); it != in.end(); ++it)
@@ -153,7 +153,7 @@ namespace crow
153153
}
154154
}
155155

156-
bool isTagInsideObjectBlock(const int& current, const std::vector<context*>& stack)
156+
bool isTagInsideObjectBlock(const int& current, const std::vector<context*>& stack) const
157157
{
158158
int openedBlock = 0;
159159
int totalBlocksBefore = 0;
@@ -179,7 +179,7 @@ namespace crow
179179
return false;
180180
}
181181

182-
void render_internal(int actionBegin, int actionEnd, std::vector<context*>& stack, std::string& out, int indent)
182+
void render_internal(int actionBegin, int actionEnd, std::vector<context*>& stack, std::string& out, int indent) const
183183
{
184184
int current = actionBegin;
185185

@@ -323,7 +323,7 @@ namespace crow
323323
auto& fragment = fragments_[actionEnd];
324324
render_fragment(fragment, indent, out);
325325
}
326-
void render_fragment(const std::pair<int, int> fragment, int indent, std::string& out)
326+
void render_fragment(const std::pair<int, int> fragment, int indent, std::string& out) const
327327
{
328328
if (indent)
329329
{
@@ -339,7 +339,7 @@ namespace crow
339339
}
340340

341341
public:
342-
std::string render()
342+
std::string render() const
343343
{
344344
context empty_ctx;
345345
std::vector<context*> stack;
@@ -349,7 +349,7 @@ namespace crow
349349
render_internal(0, fragments_.size() - 1, stack, ret, 0);
350350
return ret;
351351
}
352-
std::string render(context& ctx)
352+
std::string render(context& ctx) const
353353
{
354354
std::vector<context*> stack;
355355
stack.emplace_back(&ctx);

0 commit comments

Comments
 (0)