Class: Liquid2::InlineComment

Inherits:
Tag
  • Object
show all
Defined in:
lib/liquid2/nodes/tags/inline_comment.rb

Overview

{% # comment %} style comments.

Instance Attribute Summary collapse

Attributes inherited from Node

#blank, #token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tag

#name

Methods inherited from Node

#block_scope, #children, #expressions, #partial_scope, #render_with_disabled_tag_check, #template_scope

Constructor Details

#initialize(token, text) ⇒ InlineComment

Returns a new instance of InlineComment.

Parameters:

  • text (String)

Raises:



18
19
20
21
22
23
24
# File 'lib/liquid2/nodes/tags/inline_comment.rb', line 18

def initialize(token, text)
  super(token)
  @text = text
  return unless /\n\s*[^#\s]/.match?(text)

  raise LiquidSyntaxError.new("every line must start with a '#'", token)
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



8
9
10
# File 'lib/liquid2/nodes/tags/inline_comment.rb', line 8

def text
  @text
end

Class Method Details

.parse(token, parser) ⇒ Object



10
11
12
13
14
15
# File 'lib/liquid2/nodes/tags/inline_comment.rb', line 10

def self.parse(token, parser)
  comment = parser.eat(:token_comment)
  parser.carry_whitespace_control
  parser.eat(:token_tag_end)
  new(token, comment[1] || "")
end

Instance Method Details

#render(_context, _buffer) ⇒ Object



26
# File 'lib/liquid2/nodes/tags/inline_comment.rb', line 26

def render(_context, _buffer) = 0