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, #count_width, #indent_label, #next_indent, #next_width, #replace_hard_tabs, #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 |
# 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(/\[.*\]/) return ast << [:static, " #{text} "] end content = with_indented { parse_lines } [:haml, :comment, text, content] end |