]> Creatis software - cpPlugins.git/blob - lib/mstch/state/outside_section.cpp
Moved to version 1.0
[cpPlugins.git] / lib / mstch / state / outside_section.cpp
1 #include "outside_section.hpp"
2
3 #include "visitor/render_node.hpp"
4 #include "in_section.hpp"
5 #include "render_context.hpp"
6
7 using namespace mstch;
8
9 std::string outside_section::render(
10     render_context& ctx, const token& token)
11 {
12   using flag = render_node::flag;
13   switch (token.token_type()) {
14     case token::type::section_open:
15       ctx.set_state<in_section>(in_section::type::normal, token);
16       break;
17     case token::type::inverted_section_open:
18       ctx.set_state<in_section>(in_section::type::inverted, token);
19       break;
20     case token::type::variable:
21       return visit(render_node(ctx, flag::escape_html), ctx.get_node(token.name()));
22     case token::type::unescaped_variable:
23       return visit(render_node(ctx, flag::none), ctx.get_node(token.name()));
24     case token::type::text:
25       return token.raw();
26     case token::type::partial:
27       return ctx.render_partial(token.name(), token.partial_prefix());
28     default:
29       break;
30   }
31   return "";
32 }