X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fmstch%2Fstate%2Foutside_section.cpp;fp=lib%2Fmstch%2Fstate%2Foutside_section.cpp;h=c9817b19fb6d30211c4b09b84b8906948006e245;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=0000000000000000000000000000000000000000;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/mstch/state/outside_section.cpp b/lib/mstch/state/outside_section.cpp new file mode 100644 index 0000000..c9817b1 --- /dev/null +++ b/lib/mstch/state/outside_section.cpp @@ -0,0 +1,32 @@ +#include "outside_section.hpp" + +#include "visitor/render_node.hpp" +#include "in_section.hpp" +#include "render_context.hpp" + +using namespace mstch; + +std::string outside_section::render( + render_context& ctx, const token& token) +{ + using flag = render_node::flag; + switch (token.token_type()) { + case token::type::section_open: + ctx.set_state(in_section::type::normal, token); + break; + case token::type::inverted_section_open: + ctx.set_state(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; + } + return ""; +}