diff options
| author | Mistivia <i@mistivia.com> | 2025-01-16 15:43:04 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-01-16 15:53:58 +0800 |
| commit | 8689a7c78c50676ea739f52fbcee9f091709f5c0 (patch) | |
| tree | bbb72c68e5e1753f751133941a402caa43e29a16 /lib/mstch/src/state/outside_section.cpp | |
| parent | 00afb767ae37488d99f78363d031b898b1932354 (diff) | |
add mstch
Diffstat (limited to 'lib/mstch/src/state/outside_section.cpp')
| -rw-r--r-- | lib/mstch/src/state/outside_section.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/mstch/src/state/outside_section.cpp b/lib/mstch/src/state/outside_section.cpp new file mode 100644 index 0000000..c9817b1 --- /dev/null +++ b/lib/mstch/src/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>(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; + } + return ""; +} |
