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

Instance Method Summary collapse

Instance Attribute Details

#subnodesObject (readonly)

The nodes the tag contains



19
20
21
# File 'lib/inversion/template/containertag.rb', line 19

def subnodes
  @subnodes
end

Instance Method Details

#<<(node) ⇒ Object

Append operator: add nodes to the correct part of the parse tree.



23
24
25
26
# File 'lib/inversion/template/containertag.rb', line 23

def <<( node )
	@subnodes << node
	return self
end

#initialize {|_self| ... } ⇒ Object

Setup subnodes for including classes. :notnew:

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
15
# File 'lib/inversion/template/containertag.rb', line 11

def initialize( * )
	@subnodes = []
	super
	yield( self ) if block_given?
end

#is_container?Boolean Also known as: container?

Tell the parser to expect a matching <?end ?> tag.

Returns:

  • (Boolean)


30
31
32
# File 'lib/inversion/template/containertag.rb', line 30

def is_container?
	return true
end

#render(renderstate) ⇒ Object

Default render method for containertags; rendering each of its subnodes and don’t render anything for the container itself.



38
39
40
# File 'lib/inversion/template/containertag.rb', line 38

def render( renderstate )
	self.render_subnodes( renderstate )
end

#render_subnodes(renderstate) ⇒ Object

Append the container’s subnodes to the renderstate.



44
45
46
# File 'lib/inversion/template/containertag.rb', line 44

def render_subnodes( renderstate )
	self.subnodes.each {|node| renderstate << node }
end