Module: Inversion::Template::ContainerTag
- Included in:
- BeginTag, CommentTag, ForTag, FragmentTag, IfTag, PublishTag, UnlessTag
- Defined in:
- lib/inversion/template/containertag.rb
Overview
A mixin for a tag that allows it to contain other nodes.
Instance Attribute Summary collapse
-
#subnodes ⇒ Object
readonly
The nodes the tag contains.
Instance Method Summary collapse
-
#<<(node) ⇒ Object
Append operator: add nodes to the correct part of the parse tree.
-
#initialize {|_self| ... } ⇒ Object
Setup subnodes for including classes.
-
#is_container? ⇒ Boolean
(also: #container?)
Tell the parser to expect a matching <?end ?> tag.
-
#render(renderstate) ⇒ Object
Default render method for containertags; rendering each of its subnodes and don’t render anything for the container itself.
-
#render_subnodes(renderstate) ⇒ Object
Append the container’s subnodes to the ‘renderstate`.
Instance Attribute Details
permalink #subnodes ⇒ Object (readonly)
The nodes the tag contains
18 19 20 |
# File 'lib/inversion/template/containertag.rb', line 18 def subnodes @subnodes end |
Instance Method Details
permalink #<<(node) ⇒ Object
Append operator: add nodes to the correct part of the parse tree.
22 23 24 25 |
# File 'lib/inversion/template/containertag.rb', line 22 def <<( node ) @subnodes << node return self end |
permalink #initialize {|_self| ... } ⇒ Object
Setup subnodes for including classes. :notnew:
10 11 12 13 14 |
# File 'lib/inversion/template/containertag.rb', line 10 def initialize( * ) @subnodes = [] super yield( self ) if block_given? end |
permalink #is_container? ⇒ Boolean Also known as: container?
Tell the parser to expect a matching <?end ?> tag.
29 30 31 |
# File 'lib/inversion/template/containertag.rb', line 29 def is_container? return true end |
permalink #render(renderstate) ⇒ Object
Default render method for containertags; rendering each of its subnodes and don’t render anything for the container itself.
37 38 39 |
# File 'lib/inversion/template/containertag.rb', line 37 def render( renderstate ) self.render_subnodes( renderstate ) end |
permalink #render_subnodes(renderstate) ⇒ Object
Append the container’s subnodes to the ‘renderstate`.
43 44 45 |
# File 'lib/inversion/template/containertag.rb', line 43 def render_subnodes( renderstate ) self.subnodes.each {|node| renderstate << node } end |