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

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
# File 'lib/liquid/tags/raw.rb', line 6

def initialize(tag_name, markup, parse_context)
  super

  ensure_valid_markup(tag_name, markup, parse_context)
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


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

def blank?
  @body.empty?
end

#nodelistObject



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

def nodelist
  [@body]
end

#parse(tokens) ⇒ Object

Raises:



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

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



25
26
27
# File 'lib/liquid/tags/raw.rb', line 25

def render(_context)
  @body
end