Class: Liquid2::WithTag
- Inherits:
-
Tag
show all
- Defined in:
- lib/liquid2/nodes/tags/with.rb
Overview
Constant Summary
collapse
- END_BLOCK =
Set["endwith"]
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
#expressions, #partial_scope, #render_with_disabled_tag_check, #template_scope
Constructor Details
#initialize(token, args, block) ⇒ WithTag
Returns a new instance of WithTag.
27
28
29
30
31
32
|
# File 'lib/liquid2/nodes/tags/with.rb', line 27
def initialize(token, args, block)
super(token)
@args = args
@block = block
@blank = block.blank
end
|
Class Method Details
.parse(token, parser) ⇒ WithTag
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/liquid2/nodes/tags/with.rb', line 13
def self.parse(token, parser)
parser.next if parser.current_kind == :token_comma
args = parser.parse_keyword_arguments
parser.next if parser.current_kind == :token_comma
parser.carry_whitespace_control
parser.eat(:token_tag_end)
block = parser.parse_block(END_BLOCK)
parser.eat_empty_tag("endwith")
new(token, args, block)
end
|
Instance Method Details
#block_scope ⇒ Object
42
|
# File 'lib/liquid2/nodes/tags/with.rb', line 42
def block_scope = @args.map { |arg| Identifier.new(arg.token) }
|
#children(_static_context, include_partials: true) ⇒ Object
41
|
# File 'lib/liquid2/nodes/tags/with.rb', line 41
def children(_static_context, include_partials: true) = [@block]
|
#render(context, buffer) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/liquid2/nodes/tags/with.rb', line 34
def render(context, buffer)
namespace = @args.to_h { |arg| [arg.name, context.evaluate(arg.value)] }
context.extend(namespace) do
@block.render(context, buffer)
end
end
|