Class: Liquid::Raw

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

Constant Summary collapse

Syntax =
/\A\s*\z/
FullTokenPossiblyInvalid =
/\A(.*)#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}\z/om

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, #render, #unknown_tag

Methods inherited from Tag

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

Methods included from ParserSwitching

#parse_with_selected_parser

Constructor Details

#initialize(tag_name, markup, parse_context) ⇒ Raw

Returns a new instance of Raw.


8
9
10
11
12
# File 'lib/liquid/tags/raw.rb', line 8

def initialize(tag_name, markup, parse_context)
  super

  ensure_valid_markup(tag_name, markup, parse_context)
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/liquid/tags/raw.rb', line 36

def blank?
  @body.empty?
end

#nodelistObject


32
33
34
# File 'lib/liquid/tags/raw.rb', line 32

def nodelist
  [@body]
end

#parse(tokens) ⇒ Object

Raises:


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/liquid/tags/raw.rb', line 14

def parse(tokens)
  @body = +''
  while (token = tokens.shift)
    if token =~ FullTokenPossiblyInvalid
      @body << Regexp.last_match(1) if Regexp.last_match(1) != ""
      return if block_delimiter == Regexp.last_match(2)
    end
    @body << token unless token.empty?
  end

  raise SyntaxError, parse_context.locale.t("errors.syntax.tag_never_closed", block_name: block_name)
end

#render_to_output_buffer(_context, output) ⇒ Object


27
28
29
30
# File 'lib/liquid/tags/raw.rb', line 27

def render_to_output_buffer(_context, output)
  output << @body
  output
end