Class: Luoma::CaptureTag

Inherits:
Markup
  • Object
show all
Defined in:
lib/luoma/tags/capture.rb,
sig/luoma/tags/capture.rbs

Constant Summary collapse

END_CAPTURE_BLOCK =

Returns:

  • (Set[String])
Set["endcapture"]

Instance Attribute Summary

Attributes inherited from Markup

#blank, #tag_name, #token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Markup

#block_scope, #expressions, #partial

Constructor Details

#initialize(token, tag_name, identifier, block) ⇒ CaptureTag

Returns a new instance of CaptureTag.

Signature:

  • (t_token, String, Name, t_block) -> void

Parameters:

  • token (t_token)
  • tag_name (String)
  • identifier (Name)
  • block (t_block)


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

Parameters:

  • token (t_token)
  • tag_name (String)
  • parser (Parser)

Returns:



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

Signature:

  • (RenderContext) -> Array[Markup]



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

Signature:

  • (RenderContext, String) -> void



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_scopeObject

Signature:

  • () -> Array[Name]



39
40
41
# File 'lib/luoma/tags/capture.rb', line 39

def template_scope
  [@identifier]
end