Class: Liquid::Tag

Inherits:
Object
  • Object
show all
Includes:
ParserSwitching
Defined in:
lib/liquid/tag.rb,
lib/liquid/tag/disabler.rb,
lib/liquid/tag/disableable.rb

Defined Under Namespace

Modules: Disableable, Disabler

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ParserSwitching

#parse_with_selected_parser, #strict_parse_with_error_mode_fallback

Constructor Details

#initialize(tag_name, markup, parse_context) ⇒ Tag

Returns a new instance of Tag.


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

def initialize(tag_name, markup, parse_context)
  @tag_name      = tag_name
  @markup        = markup
  @parse_context = parse_context
  @line_number   = parse_context.line_number
end

Instance Attribute Details

#line_numberObject (readonly)

Returns the value of attribute line_number.


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

def line_number
  @line_number
end

#nodelistObject (readonly)

Returns the value of attribute nodelist.


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

def nodelist
  @nodelist
end

#parse_contextObject (readonly) Also known as: options

Returns the value of attribute parse_context.


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

def parse_context
  @parse_context
end

#tag_nameObject (readonly)

Returns the value of attribute tag_name.


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

def tag_name
  @tag_name
end

Class Method Details

.disable_tags(*tag_names) ⇒ Object


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

def disable_tags(*tag_names)
  tag_names += disabled_tags
  define_singleton_method(:disabled_tags) { tag_names }
  prepend(Disabler)
end

.parse(tag_name, markup, tokenizer, parse_context) ⇒ Object


10
11
12
13
14
# File 'lib/liquid/tag.rb', line 10

def parse(tag_name, markup, tokenizer, parse_context)
  tag = new(tag_name, markup, parse_context)
  tag.parse(tokenizer)
  tag
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)

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

def blank?
  false
end

#nameObject


45
46
47
# File 'lib/liquid/tag.rb', line 45

def name
  self.class.name.downcase
end

#parse(_tokens) ⇒ Object


38
39
# File 'lib/liquid/tag.rb', line 38

def parse(_tokens)
end

#rawObject


41
42
43
# File 'lib/liquid/tag.rb', line 41

def raw
  "#{@tag_name} #{@markup}"
end

#render(_context) ⇒ Object


49
50
51
# File 'lib/liquid/tag.rb', line 49

def render(_context)
  ''
end

#render_to_output_buffer(context, output) ⇒ Object

For backwards compatibility with custom tags. In a future release, the semantics of the `render_to_output_buffer` method will become the default and the `render` method will be removed.


56
57
58
59
# File 'lib/liquid/tag.rb', line 56

def render_to_output_buffer(context, output)
  output << render(context)
  output
end