Class: Liquid::Block
Constant Summary
collapse
- MAX_DEPTH =
100
Instance Attribute Summary
Attributes inherited from Tag
#line_number, #parse_context, #tag_name
Instance Method Summary
collapse
Methods inherited from Tag
#name, parse, #raw
#parse_with_selected_parser
Constructor Details
#initialize(tag_name, markup, options) ⇒ Block
Returns a new instance of Block.
5
6
7
8
|
# File 'lib/liquid/block.rb', line 5
def initialize(tag_name, markup, options)
super
@blank = true
end
|
Instance Method Details
#blank? ⇒ Boolean
20
21
22
|
# File 'lib/liquid/block.rb', line 20
def blank?
@blank
end
|
#block_delimiter ⇒ Object
46
47
48
|
# File 'lib/liquid/block.rb', line 46
def block_delimiter
@block_delimiter ||= "end#{block_name}"
end
|
#block_name ⇒ Object
42
43
44
|
# File 'lib/liquid/block.rb', line 42
def block_name
@tag_name
end
|
#nodelist ⇒ Object
24
25
26
|
# File 'lib/liquid/block.rb', line 24
def nodelist
@body.nodelist
end
|
#parse(tokens) ⇒ Object
10
11
12
13
14
|
# File 'lib/liquid/block.rb', line 10
def parse(tokens)
@body = BlockBody.new
while parse_body(@body, tokens)
end
end
|
#render(context) ⇒ Object
16
17
18
|
# File 'lib/liquid/block.rb', line 16
def render(context)
@body.render(context)
end
|
#unknown_tag(tag, _params, _tokens) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/liquid/block.rb', line 28
def unknown_tag(tag, _params, _tokens)
if tag == 'else'.freeze
raise SyntaxError.new(parse_context.locale.t("errors.syntax.unexpected_else".freeze,
block_name: block_name))
elsif tag.start_with?('end'.freeze)
raise SyntaxError.new(parse_context.locale.t("errors.syntax.invalid_delimiter".freeze,
tag: tag,
block_name: block_name,
block_delimiter: block_delimiter))
else
raise SyntaxError.new(parse_context.locale.t("errors.syntax.unknown_tag".freeze, tag: tag))
end
end
|