From 5d94984c6c8dedf1fc5211b9253b37262f0d0fb3 Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Thu, 1 Oct 2015 18:18:44 +0200 Subject: [PATCH] reference bug fix --- src/render_context.cpp | 13 ++++++++----- src/render_context.hpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/render_context.cpp b/src/render_context.cpp index 89ab657..d32d629 100644 --- a/src/render_context.cpp +++ b/src/render_context.cpp @@ -32,20 +32,23 @@ render_context::render_context( const mstch::node& render_context::find_node( const std::string& token, - const std::deque& current_nodes) + std::deque current_nodes) { if (token != "." && token.find('.') != std::string::npos) 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 for (auto& node: current_nodes) - if (visit(has_token(token), node)) - return visit(get_token(token, node), node); + if (visit(has_token(token), *node)) + return visit(get_token(token, *node), *node); return null_node; } const mstch::node& render_context::get_node(const std::string& token) { - return find_node(token, nodes); + std::deque current_nodes; + for (auto& node: nodes) + current_nodes.push_back(&node); + return find_node(token, current_nodes); } std::string render_context::render( diff --git a/src/render_context.hpp b/src/render_context.hpp index b8039c3..20bc12b 100644 --- a/src/render_context.hpp +++ b/src/render_context.hpp @@ -40,7 +40,7 @@ class render_context { static const mstch::node null_node; const mstch::node& find_node( const std::string& token, - const std::deque& current_nodes); + std::deque current_nodes); std::map partials; std::deque nodes; std::stack> state;