Class: Luoma::DefineTag
- Defined in:
- lib/luoma/tags/define.rb,
sig/luoma/tags/define.rbs
Constant Summary collapse
- END_DEFINE_BLOCK =
Set["enddefine"]
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) ⇒ DefineTag
constructor
A new instance of DefineTag.
- #render(context, buffer) ⇒ Object
- #template_scope ⇒ Object
Methods inherited from Markup
#block_scope, #expressions, #partial
Constructor Details
#initialize(token, tag_name, identifier, block) ⇒ DefineTag
Returns a new instance of DefineTag.
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
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
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
28 29 30 |
# File 'lib/luoma/tags/define.rb', line 28 def render(context, buffer) context.assign(@identifier.value, @drop) end |
#template_scope ⇒ Object
38 39 40 |
# File 'lib/luoma/tags/define.rb', line 38 def template_scope [@identifier] end |