Class: Luoma::DefineTag

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

Constant Summary collapse

END_DEFINE_BLOCK =

Returns:

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

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) ⇒ DefineTag

Returns a new instance of DefineTag.

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
25
# File 'lib/luoma/tags/define.rb', line 18

def initialize(token, tag_name, identifier, block)
  super(token)
  @tag_name = tag_name
  @identifier = identifier
  @block = block
  @blank = true
  @drop = BlockDrop.new(block)
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/define.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_DEFINE_BLOCK)
  parser.eat_empty_tag("enddefine")
  new(token, tag_name, identifier, block)
end

Instance Method Details

#children(static_context) ⇒ Object

Signature:

  • (RenderContext) -> Array[Markup]



33
34
35
# File 'lib/luoma/tags/define.rb', line 33

def children(static_context)
  @block.grep_v(String) #: Array[Markup]
end

#render(context, buffer) ⇒ Object

Signature:

  • (RenderContext, String) -> void



28
29
30
# File 'lib/luoma/tags/define.rb', line 28

def render(context, buffer)
  context.assign(@identifier.value, @drop)
end

#template_scopeObject

Signature:

  • () -> Array[Name]



38
39
40
# File 'lib/luoma/tags/define.rb', line 38

def template_scope
  [@identifier]
end