Class: Liquid2::CaptureTag
- Inherits:
-
Tag
- Object
- Node
- Tag
- Liquid2::CaptureTag
show all
- Defined in:
- lib/liquid2/nodes/tags/capture.rb
Overview
The standard capture tag.
Constant Summary
collapse
- END_BLOCK =
Set["endcapture"]
Instance Attribute Summary
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, #expressions, #partial_scope, #render_with_disabled_tag_check
Constructor Details
#initialize(token, name, block) ⇒ CaptureTag
Returns a new instance of CaptureTag.
23
24
25
26
27
28
29
|
# File 'lib/liquid2/nodes/tags/capture.rb', line 23
def initialize(token, name, block)
super(token)
@name = name
@block = block
@block.blank = false
@blank = true
end
|
Class Method Details
.parse(token, parser) ⇒ CaptureTag
12
13
14
15
16
17
18
19
|
# File 'lib/liquid2/nodes/tags/capture.rb', line 12
def self.parse(token, parser)
name = parser.parse_identifier(trailing_question: false)
parser.carry_whitespace_control
parser.eat(:token_tag_end)
block = parser.parse_block(END_BLOCK)
parser.eat_empty_tag("endcapture")
new(token, name, block)
end
|
Instance Method Details
#children(_static_context, include_partials: true) ⇒ Object
37
|
# File 'lib/liquid2/nodes/tags/capture.rb', line 37
def children(_static_context, include_partials: true) = [@block]
|
#render(context, _buffer) ⇒ Object
31
32
33
34
35
|
# File 'lib/liquid2/nodes/tags/capture.rb', line 31
def render(context, _buffer)
buf = +""
@block.render(context, buf)
context.assign(@name.name, buf)
end
|
#template_scope ⇒ Object
38
|
# File 'lib/liquid2/nodes/tags/capture.rb', line 38
def template_scope = [@name]
|