Class: Liquid::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid/tag.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens, options) ⇒ Tag

Returns a new instance of Tag.



15
16
17
18
19
20
21
# File 'lib/liquid/tag.rb', line 15

def initialize(tag_name, markup, tokens, options)
  @tag_name   = tag_name
  @markup     = markup
  @options    = options || {}
  @line       = @options[:line] || 1
  parse(tokens)
end

Instance Attribute Details

#lineObject

Returns the value of attribute line.



3
4
5
# File 'lib/liquid/tag.rb', line 3

def line
  @line
end

#nodelistObject

Returns the value of attribute nodelist.



3
4
5
# File 'lib/liquid/tag.rb', line 3

def nodelist
  @nodelist
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/liquid/tag.rb', line 3

def options
  @options
end

#warningsObject (readonly)

Returns the value of attribute warnings.



4
5
6
# File 'lib/liquid/tag.rb', line 4

def warnings
  @warnings
end

Class Method Details

.new_with_options(tag_name, markup, tokens, options) ⇒ Object



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

def self.new_with_options(tag_name, markup, tokens, options)
  # Forgive me Matz for I have sinned. I know this code is weird
  # but it was necessary to maintain API compatibility.
  new_tag = self.allocate
  new_tag.options = options
  new_tag.send(:initialize, tag_name, markup, tokens, options)
  new_tag
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/liquid/tag.rb', line 34

def blank?
  @blank || true
end

#nameObject



26
27
28
# File 'lib/liquid/tag.rb', line 26

def name
  self.class.name.downcase
end

#parse(tokens) ⇒ Object



23
24
# File 'lib/liquid/tag.rb', line 23

def parse(tokens)
end

#parse_with_selected_parser(markup) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/liquid/tag.rb', line 38

def parse_with_selected_parser(markup)
  case @options[:error_mode] || Template.error_mode
  when :strict then strict_parse_with_error_context(markup)
  when :lax    then lax_parse(markup)
  when :warn
    begin
      return strict_parse_with_error_context(markup)
    rescue SyntaxError => e
      @warnings ||= []
      @warnings << e
      return lax_parse(markup)
    end
  end
end

#render(context) ⇒ Object



30
31
32
# File 'lib/liquid/tag.rb', line 30

def render(context)
  ''
end