reference bug fix

This commit is contained in:
Daniel Sipka 2015-10-01 18:18:44 +02:00
parent a3f01595d7
commit 5d94984c6c
2 changed files with 9 additions and 6 deletions

View file

@ -32,20 +32,23 @@ render_context::render_context(
const mstch::node& render_context::find_node( const mstch::node& render_context::find_node(
const std::string& token, const std::string& token,
const std::deque<node>& current_nodes) std::deque<node const*> current_nodes)
{ {
if (token != "." && token.find('.') != std::string::npos) if (token != "." && token.find('.') != std::string::npos)
return find_node(token.substr(token.rfind('.') + 1), return find_node(token.substr(token.rfind('.') + 1),
{find_node(token.substr(0, token.rfind('.')), current_nodes)}); {&find_node(token.substr(0, token.rfind('.')), current_nodes)});
else else
for (auto& node: current_nodes) for (auto& node: current_nodes)
if (visit(has_token(token), node)) if (visit(has_token(token), *node))
return visit(get_token(token, node), node); return visit(get_token(token, *node), *node);
return null_node; return null_node;
} }
const mstch::node& render_context::get_node(const std::string& token) { const mstch::node& render_context::get_node(const std::string& token) {
return find_node(token, nodes); std::deque<node const*> current_nodes;
for (auto& node: nodes)
current_nodes.push_back(&node);
return find_node(token, current_nodes);
} }
std::string render_context::render( std::string render_context::render(

View file

@ -40,7 +40,7 @@ class render_context {
static const mstch::node null_node; static const mstch::node null_node;
const mstch::node& find_node( const mstch::node& find_node(
const std::string& token, const std::string& token,
const std::deque<node>& current_nodes); std::deque<node const*> current_nodes);
std::map<std::string, template_type> partials; std::map<std::string, template_type> partials;
std::deque<mstch::node> nodes; std::deque<mstch::node> nodes;
std::stack<std::unique_ptr<render_state>> state; std::stack<std::unique_ptr<render_state>> state;