| 1962 | } |
| 1963 | |
| 1964 | void TemplateParser::parse_var() |
| 1965 | { |
| 1966 | size_t pos = m_text.find("}"); |
| 1967 | if (pos == std::string::npos) |
| 1968 | { |
| 1969 | throw TemplateException(m_current_line, "unterminated variable block"); |
| 1970 | } |
| 1971 | |
| 1972 | std::string var_text = m_text.substr(1, pos - 1); |
| 1973 | |
| 1974 | bool has_kill_newline_if_empty = !var_text.empty() && var_text[0] == '>' && var_text.size() > 2; |
| 1975 | if (has_kill_newline_if_empty) |
| 1976 | { |
| 1977 | var_text = var_text.substr(1, pos - 2); |
| 1978 | } |
| 1979 | |
| 1980 | bool has_kill_newline = !var_text.empty() && var_text.back() == '>'; |
| 1981 | if (has_kill_newline) |
| 1982 | { |
| 1983 | var_text.pop_back(); |
| 1984 | } |
| 1985 | |
| 1986 | bool eol_follows = m_text.size() > pos + 1 && m_text[pos + 1] == '\n'; |
| 1987 | m_text = m_text.substr(pos + 1 + (has_kill_newline && eol_follows ? 1 : 0)); |
| 1988 | |
| 1989 | token_vector stmt_tokens = tokenize_statement(var_text); |
| 1990 | m_current_nodes->push_back(node_ptr(new NodeVar(stmt_tokens, m_current_line, has_kill_newline_if_empty))); |
| 1991 | |
| 1992 | m_current_line += count_newlines(var_text); |
| 1993 | m_last_was_eol = false; |
| 1994 | } |
| 1995 | |
| 1996 | void TemplateParser::push_node(Node *new_node, token_type_t until) |
| 1997 | { |
nothing calls this directly
no test coverage detected