diff --git a/src/template_type.cpp b/src/template_type.cpp index 53f6e81..355c4f6 100644 --- a/src/template_type.cpp +++ b/src/template_type.cpp @@ -74,10 +74,7 @@ void template_type::strip_whitespace() { if ((*it).eol()) { if (has_tag && !non_space) { - for (auto cur = line_begin; !(*cur).eol(); ++cur) - if ((*cur).token_type() == token::type::partial && - cur != line_begin && (*(cur - 1)).ws_only()) - (*cur).partial_prefix((*(cur - 1)).raw()); + store_prefixes(line_begin); for (auto cur = line_begin; it != cur - 1; cur = (*cur).ws_only() ? tokens.erase(cur) : cur + 1) @@ -89,3 +86,10 @@ void template_type::strip_whitespace() { } } } + +void template_type::store_prefixes(std::vector::iterator beg) { + for (auto cur = beg; !(*cur).eol(); ++cur) + if ((*cur).token_type() == token::type::partial && + cur != beg && (*(cur - 1)).ws_only()) + (*cur).partial_prefix((*(cur - 1)).raw()); +} diff --git a/src/template_type.hpp b/src/template_type.hpp index 2a46b8d..4dfe826 100644 --- a/src/template_type.hpp +++ b/src/template_type.hpp @@ -21,6 +21,7 @@ class template_type { void strip_whitespace(); void process_text(citer beg, citer end); void tokenize(const std::string& tmp); + void store_prefixes(std::vector::iterator beg); }; } diff --git a/src/visitor/has_token.hpp b/src/visitor/has_token.hpp index 2efb627..1d15443 100644 --- a/src/visitor/has_token.hpp +++ b/src/visitor/has_token.hpp @@ -12,7 +12,7 @@ class has_token: public boost::static_visitor { } template - inline bool operator()(const T& t) const { + bool operator()(const T& t) const { return token == "."; } diff --git a/src/visitor/is_node_empty.hpp b/src/visitor/is_node_empty.hpp index bfe3012..8119d4c 100644 --- a/src/visitor/is_node_empty.hpp +++ b/src/visitor/is_node_empty.hpp @@ -9,7 +9,7 @@ namespace mstch { class is_node_empty: public boost::static_visitor { public: template - inline bool operator()(const T& t) const { + bool operator()(const T& t) const { return false; } diff --git a/src/visitor/render_node.hpp b/src/visitor/render_node.hpp index 97037a6..63b7682 100644 --- a/src/visitor/render_node.hpp +++ b/src/visitor/render_node.hpp @@ -18,7 +18,7 @@ class render_node: public boost::static_visitor { } template - inline std::string operator()(const T& t) const { + std::string operator()(const T& t) const { return ""; } diff --git a/src/visitor/render_section.hpp b/src/visitor/render_section.hpp index be26435..25592ad 100644 --- a/src/visitor/render_section.hpp +++ b/src/visitor/render_section.hpp @@ -20,7 +20,7 @@ class render_section: public boost::static_visitor { } template - inline std::string operator()(const T& t) const { + std::string operator()(const T& t) const { return render_context::push(ctx, t).render(section); }