reformat
This commit is contained in:
parent
406f730621
commit
c6164ae8c8
2 changed files with 6 additions and 8 deletions
|
@ -27,7 +27,8 @@ std::string strip_whitespace(std::string tmplt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mstch::render(
|
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)
|
const std::map<std::string,std::string>& partials)
|
||||||
{
|
{
|
||||||
return render_context(root_object, partials)
|
return render_context(root_object, partials)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#include "render_context.h"
|
#include "render_context.h"
|
||||||
#include "state/render_state.h"
|
|
||||||
#include "state/outside_section.h"
|
#include "state/outside_section.h"
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <visitor/to_json.h>
|
|
||||||
|
|
||||||
using namespace mstch;
|
using namespace mstch;
|
||||||
|
|
||||||
|
@ -32,18 +30,17 @@ const mstch::node& render_context::find_node(
|
||||||
const std::string& token,
|
const std::string& token,
|
||||||
const std::deque<object>& current_objects)
|
const std::deque<object>& current_objects)
|
||||||
{
|
{
|
||||||
if (token != "." && token.find('.') != std::string::npos) {
|
if (token != "." && token.find('.') != std::string::npos)
|
||||||
return find_node(
|
return find_node(
|
||||||
token.substr(token.rfind('.') + 1),
|
token.substr(token.rfind('.') + 1),
|
||||||
{boost::get<object>(find_node(
|
{boost::get<object>(find_node(
|
||||||
token.substr(0, token.rfind('.')),
|
token.substr(0, token.rfind('.')),
|
||||||
current_objects))});
|
current_objects))});
|
||||||
} else {
|
else
|
||||||
for (auto& object: current_objects)
|
for (auto& object: current_objects)
|
||||||
if (object.count(token) != 0)
|
if (object.count(token))
|
||||||
return object.at(token);
|
return object.at(token);
|
||||||
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) {
|
||||||
|
|
Loading…
Reference in a new issue