Class: Luoma::CaptureTag
- Defined in:
- lib/luoma/tags/capture.rb,
sig/luoma/tags/capture.rbs
Constant Summary collapse
- END_CAPTURE_BLOCK =
Set["endcapture"]
Instance Attribute Summary
Attributes inherited from Markup
Class Method Summary collapse
-
.parse(token, tag_name, parser) ⇒ Markup
(t_token, String, Parser) -> Markup.
Instance Method Summary collapse
- #children(static_context) ⇒ Object
-
#initialize(token, tag_name, identifier, block) ⇒ CaptureTag
constructor
A new instance of CaptureTag.
- #render(context, buffer) ⇒ Object
- #template_scope ⇒ Object
Methods inherited from Markup
#block_scope, #expressions, #partial
Constructor Details
#initialize(token, tag_name, identifier, block) ⇒ CaptureTag
Returns a new instance of CaptureTag.
18 19 20 21 22 23 24 |
# File 'lib/luoma/tags/capture.rb', line 18 def initialize(token, tag_name, identifier, block) super(token) @tag_name = tag_name @identifier = identifier @block = block @blank = true end |
Class Method Details
.parse(token, tag_name, parser) ⇒ Markup
(t_token, String, Parser) -> Markup
8 9 10 11 12 13 14 15 |
# File 'lib/luoma/tags/capture.rb', line 8 def self.parse(token, tag_name, parser) identifier = parser.parse_ident parser.carry_whitespace_control parser.eat(:token_tag_end) block = parser.parse_block(stop: END_CAPTURE_BLOCK) parser.eat_empty_tag("endcapture") new(token, tag_name, identifier, block) end |
Instance Method Details
#children(static_context) ⇒ Object
34 35 36 |
# File 'lib/luoma/tags/capture.rb', line 34 def children(static_context) @block.grep_v(String) #: Array[Markup] end |
#render(context, buffer) ⇒ Object
27 28 29 30 31 |
# File 'lib/luoma/tags/capture.rb', line 27 def render(context, buffer) buf = +"" Luoma.render_block(@block, context, buf) context.assign(@identifier.value, buf) end |
#template_scope ⇒ Object
39 40 41 |
# File 'lib/luoma/tags/capture.rb', line 39 def template_scope [@identifier] end |