Method: Arrow::Template#render

Defined in:
lib/arrow/template.rb

#render(nodes = nil, scope = nil, enclosing_template = nil) ⇒ Object Also known as: to_s

Render the template to text and return it as a String. If called with an Array of nodes, the template will render them instead of its own syntax_tree. If given a scope (a Module object), a Binding of its internal state it will be used as the context of evaluation for the render. If not specified, a new anonymous Module instance is created for the render. If a enclosing_template is given, make it available during rendering for variable-sharing, etc. Returns the results of each nodes’ render joined together with the default string separator (+$,+).



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/arrow/template.rb', line 485

def render( nodes=nil, scope=nil, enclosing_template=nil )
	rval = []
	nodes ||= self.get_prepped_nodes
	scope ||= self.make_rendering_scope

	self.prerender( enclosing_template )

	# Render each node
	nodes.each do |node|
		# self.log.debug "  rendering %p" % [ node ]
		begin
			rval << node.render( self, scope )
		rescue ::Exception => err
			rval << err
		end
	end

	return self.render_objects( *rval )
ensure
	self.postrender
end