Class: Luoma::IfBlock
- Defined in:
- lib/luoma/tags/if.rb,
sig/luoma/tags/if.rbs
Constant Summary collapse
- END_IF_BLOCK =
Instance Attribute Summary collapse
-
#block ⇒ t_block
readonly
Returns the value of attribute block.
-
#expression ⇒ Expression
readonly
Returns the value of attribute expression.
Attributes inherited from Markup
Class Method Summary collapse
-
.parse(tag_name, parser) ⇒ IfBlock
(Parser) -> Markup.
Instance Method Summary collapse
-
#children(static_context) ⇒ Array[Markup]
(RenderContext) -> Array.
-
#expressions ⇒ ::Array[Expression]
() -> Array.
- #filter_strings ⇒ void
-
#initialize(token, tag_name, expression, block) ⇒ IfBlock
constructor
A new instance of IfBlock.
- #render(context, buffer) ⇒ Object
Methods inherited from Markup
#block_scope, #partial, #template_scope
Constructor Details
#initialize(token, tag_name, expression, block) ⇒ IfBlock
Returns a new instance of IfBlock.
82 83 84 85 86 87 88 |
# File 'lib/luoma/tags/if.rb', line 82 def initialize(token, tag_name, expression, block) super(token) @tag_name = tag_name @expression = expression @block = block @blank = Luoma.blank_block?(block) end |
Instance Attribute Details
#block ⇒ t_block (readonly)
Returns the value of attribute block.
66 67 68 |
# File 'lib/luoma/tags/if.rb', line 66 def block @block end |
#expression ⇒ Expression (readonly)
Returns the value of attribute expression.
66 67 68 |
# File 'lib/luoma/tags/if.rb', line 66 def expression @expression end |
Class Method Details
.parse(tag_name, parser) ⇒ IfBlock
(Parser) -> Markup
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/luoma/tags/if.rb', line 71 def self.parse(tag_name, parser) parser.eat(:token_tag_start) parser.skip_whitespace_control token = parser.eat(:token_tag_name) parser.expect_expression expression = parser.parse_expression parser.carry_whitespace_control parser.eat(:token_tag_end) IfBlock.new(token, tag_name, expression, parser.parse_block(stop: END_IF_BLOCK)) end |
Instance Method Details
#children(static_context) ⇒ Array[Markup]
(RenderContext) -> Array
96 97 98 |
# File 'lib/luoma/tags/if.rb', line 96 def children(static_context) @block.grep_v(String) #: Array[Markup] end |
#expressions ⇒ ::Array[Expression]
() -> Array
101 102 103 |
# File 'lib/luoma/tags/if.rb', line 101 def expressions [@expression] end |
#filter_strings ⇒ void
This method returns an undefined value.
105 106 107 |
# File 'lib/luoma/tags/if.rb', line 105 def filter_strings @block.filter! { |node| !node.is_a?(String) } end |
#render(context, buffer) ⇒ Object
91 92 93 |
# File 'lib/luoma/tags/if.rb', line 91 def render(context, buffer) Luoma.render_block(@block, context, buffer) end |