Class: Liquid::Raw

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

Constant Summary

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

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

Methods inherited from Tag

#name, parse, #raw

Methods included from ParserSwitching

#parse_with_selected_parser

Constructor Details

#initialize(tag_name, markup, parse_context) ⇒ Raw

Returns a new instance of Raw



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

def initialize(tag_name, markup, parse_context)
  super

  unless markup =~ Syntax
    raise SyntaxError.new(parse_context.locale.t("errors.syntax.tag_unexpected_args".freeze, tag: tag_name))
  end
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


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

def blank?
  @body.empty?
end

#nodelistObject



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

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 << $1 if $1 != "".freeze
      return if block_delimiter == $2
    end
    @body << token unless token.empty?
  end

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

#render(_context) ⇒ Object



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

def render(_context)
  @body
end