Class: Liquid::Doc

Inherits:
Block show all
Defined in:
lib/liquid/tags/doc.rb

Constant Summary collapse

NO_UNEXPECTED_ARGS =
/\A\s*\z/

Constants inherited from Block

Block::MAX_DEPTH

Instance Attribute Summary

Attributes inherited from Tag

#line_number, #parse_context, #tag_name

Instance Method Summary collapse

Methods inherited from Block

#block_delimiter, #block_name, #raise_tag_never_closed, raise_unknown_tag, #render, #unknown_tag

Methods inherited from Tag

disable_tags, #name, parse, #raw, #render

Methods included from ParserSwitching

#parse_with_selected_parser, #strict_parse_with_error_mode_fallback

Constructor Details

#initialize(tag_name, markup, parse_context) ⇒ Doc

Returns a new instance of Doc.



33
34
35
36
# File 'lib/liquid/tags/doc.rb', line 33

def initialize(tag_name, markup, parse_context)
  super
  ensure_valid_markup(tag_name, markup, parse_context)
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/liquid/tags/doc.rb', line 61

def blank?
  @body.empty?
end

#nodelistObject



65
66
67
# File 'lib/liquid/tags/doc.rb', line 65

def nodelist
  [@body]
end

#parse(tokens) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/liquid/tags/doc.rb', line 38

def parse(tokens)
  @body = +""

  while (token = tokens.shift)
    tag_name = token =~ BlockBody::FullTokenPossiblyInvalid && Regexp.last_match(2)

    raise_nested_doc_error if tag_name == @tag_name

    if tag_name == block_delimiter
      parse_context.trim_whitespace = (token[-3] == WhitespaceControl)
      @body << Regexp.last_match(1) if Regexp.last_match(1) != ""
      return
    end
    @body << token unless token.empty?
  end

  raise_tag_never_closed(block_name)
end

#render_to_output_buffer(_context, output) ⇒ Object



57
58
59
# File 'lib/liquid/tags/doc.rb', line 57

def render_to_output_buffer(_context, output)
  output
end