Class: Inversion::Template::YieldTag

Inherits:
Tag
  • Object
show all
Defined in:
lib/inversion/template/yieldtag.rb

Overview

Inversion ‘yield’ tag.

A tag that yields to the block passed to Template#render (if there was one), and then inserts the resulting objects.

Example

<?yield ?>

Constant Summary

Constants inherited from Tag

Tag::TAG_PLUGIN_PATTERN

Instance Attribute Summary

Attributes inherited from Tag

#body

Attributes inherited from Node

#colnum, #linenum

Instance Method Summary collapse

Methods inherited from Tag

#as_comment_body, create, #derivatives, inherited, #initialize, load, load_all, #tagname, types, #types

Methods included from MethodUtilities

#singleton_attr_accessor, #singleton_attr_reader, #singleton_attr_writer

Methods included from AbstractClass

included

Methods included from AbstractClass::ClassMethods

#inherited, #pure_virtual

Methods inherited from Node

#after_appending, #after_rendering, #as_comment_body, #before_appending, #initialize, #is_container?, #location

Constructor Details

This class inherits a constructor from Inversion::Template::Tag

Instance Method Details

#before_rendering(renderstate) ⇒ Object

Rendering callback – call the block before the template this tag belongs to is rendered.



27
28
29
30
31
32
33
# File 'lib/inversion/template/yieldtag.rb', line 27

def before_rendering( renderstate )
	if renderstate.block
		self.log.debug "Yielding to %p before rendering." % [ renderstate.block ]
		renderstate.tag_data[ self ] = renderstate.block.call( renderstate )
		self.log.debug "  render block returned: %p" % [ @block_value ]
	end
end

#render(renderstate) ⇒ Object

Render the YieldTag by returning what the #render block returned during #before_rendering (if there was a block).



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

def render( renderstate )
	self.log.debug "Rendering as block return value: %p" % [ @block_value ]
	return renderstate.tag_data[ self ]
end