Module: Hamlit::Parsers::Comment
- Includes:
- Concerns::Indentable
- Included in:
- Hamlit::Parser
- Defined in:
- lib/hamlit/parsers/comment.rb
Instance Method Summary collapse
Methods included from Concerns::Indentable
#count_indent, #has_block?, #next_indent, #reset_indent, #same_indent?, #validate_indentation!, #with_indented
Methods included from Concerns::Error
#assert_scan!, #copmile_error!, #syntax_error, #syntax_error!
Instance Method Details
#parse_comment(scanner) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hamlit/parsers/comment.rb', line 9 def parse_comment(scanner) assert_scan!(scanner, /\//) ast = [:html, :comment] text = (scanner.scan(/.+/) || '').strip if text.empty? content = with_indented { parse_lines } return ast << [:multi, [:static, "\n"], *content] elsif !text.match(/\[.*\]/) if has_block? syntax_error!('Illegal nesting: nesting within a tag that already has content is illegal.') end return ast << [:static, " #{text} "] end content = with_indented { parse_lines } [:haml, :comment, text, content] end |