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.



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

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.



8
9
10
# File 'lib/liquid/tag.rb', line 8

def line_number
  @line_number
end

#nodelistObject (readonly)

Returns the value of attribute nodelist.



8
9
10
# File 'lib/liquid/tag.rb', line 8

def nodelist
  @nodelist
end

#parse_contextObject (readonly) Also known as: options

Returns the value of attribute parse_context.



8
9
10
# File 'lib/liquid/tag.rb', line 8

def parse_context
  @parse_context
end

#tag_nameObject (readonly)

Returns the value of attribute tag_name.



8
9
10
# File 'lib/liquid/tag.rb', line 8

def tag_name
  @tag_name
end

Class Method Details

.disable_tags(*tag_names) ⇒ Object



19
20
21
22
23
# File 'lib/liquid/tag.rb', line 19

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



13
14
15
16
17
# File 'lib/liquid/tag.rb', line 13

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)


65
66
67
# File 'lib/liquid/tag.rb', line 65

def blank?
  false
end

#nameObject



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

def name
  self.class.name.downcase
end

#parse(_tokens) ⇒ Object



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

def parse(_tokens)
end

#rawObject



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

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

#render(_context) ⇒ Object



52
53
54
# File 'lib/liquid/tag.rb', line 52

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.



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

def render_to_output_buffer(context, output)
  render_result = render(context)
  output << render_result if render_result
  output
end