This commit is contained in:
Daniel Sipka 2015-04-11 16:29:12 +02:00
parent 406f730621
commit c6164ae8c8
2 changed files with 6 additions and 8 deletions

View File

@ -27,7 +27,8 @@ std::string strip_whitespace(std::string tmplt) {
}
std::string mstch::render(
const std::string& tmplt, const object& root_object,
const std::string& tmplt,
const object& root_object,
const std::map<std::string,std::string>& partials)
{
return render_context(root_object, partials)

View File

@ -1,9 +1,7 @@
#include "render_context.h"
#include "state/render_state.h"
#include "state/outside_section.h"
#include <regex>
#include <visitor/to_json.h>
using namespace mstch;
@ -32,18 +30,17 @@ const mstch::node& render_context::find_node(
const std::string& token,
const std::deque<object>& current_objects)
{
if (token != "." && token.find('.') != std::string::npos) {
if (token != "." && token.find('.') != std::string::npos)
return find_node(
token.substr(token.rfind('.') + 1),
{boost::get<object>(find_node(
token.substr(0, token.rfind('.')),
current_objects))});
} else {
else
for (auto& object: current_objects)
if (object.count(token) != 0)
if (object.count(token))
return object.at(token);
return null_node;
}
return null_node;
}
const mstch::node& render_context::get_node(const std::string& token) {