Class: Luoma::ElseBlock

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

Instance Attribute Summary collapse

Attributes inherited from Markup

#blank, #tag_name, #token

Instance Method Summary collapse

Methods inherited from Markup

#block_scope, #expressions, #partial, #template_scope

Constructor Details

#initialize(token, tag_name, block) ⇒ ElseBlock

(t_token, String, t_block) -> void

Parameters:

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


8
9
10
11
12
13
14
# File 'lib/luoma/tags/else.rb', line 8

def initialize(token, tag_name, block)
  super(token)
  @tag_name = tag_name
  @expression = BooleanLiteral.new(token, true)
  @block = block
  @blank = Luoma.blank_block?(block)
end

Instance Attribute Details

#blockt_block (readonly)

Returns the value of attribute block.

Returns:

  • (t_block)


5
6
7
# File 'lib/luoma/tags/else.rb', line 5

def block
  @block
end

#expressionExpression (readonly)

Returns the value of attribute expression.

Returns:



5
6
7
# File 'lib/luoma/tags/else.rb', line 5

def expression
  @expression
end

Instance Method Details

#children(static_context) ⇒ Object

Signature:

  • (RenderContext) -> Array[Markup]



22
23
24
# File 'lib/luoma/tags/else.rb', line 22

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

#filter_stringsObject

Returns:

  • (Object)


26
27
28
# File 'lib/luoma/tags/else.rb', line 26

def filter_strings
  @block.filter! { |node| !node.is_a?(String) }
end

#render(context, buffer) ⇒ Object

Signature:

  • (RenderContext, String) -> void



17
18
19
# File 'lib/luoma/tags/else.rb', line 17

def render(context, buffer)
  Luoma.render_block(@block, context, buffer)
end