Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libmustache/state/outside_section.cpp

33 lines
948 B
C++
Raw Normal View History

2017-10-11 18:48:27 +05:00
#include "outside_section.hpp"
2017-10-17 19:29:56 +05:00
#include "../render_context.hpp"
2017-10-11 18:48:27 +05:00
#include "../visitor/render_node.hpp"
#include "in_section.hpp"
using namespace mstch;
2017-10-17 19:29:56 +05:00
std::string outside_section::render(render_context &ctx, const token &token)
2017-10-11 18:48:27 +05:00
{
using flag = render_node::flag;
2017-10-17 19:29:56 +05:00
switch (token.token_type())
{
case token::type::section_open:
ctx.set_state<in_section>(in_section::type::normal, token);
break;
case token::type::inverted_section_open:
ctx.set_state<in_section>(in_section::type::inverted, token);
break;
case token::type::variable:
return visit(render_node(ctx, flag::escape_html), ctx.get_node(token.name()));
case token::type::unescaped_variable:
return visit(render_node(ctx, flag::none), ctx.get_node(token.name()));
case token::type::text:
return token.raw();
case token::type::partial:
return ctx.render_partial(token.name(), token.partial_prefix());
default:
break;
2017-10-11 18:48:27 +05:00
}
return "";
}