Module: Flame::Render

Included in:
Controller
Defined in:
lib/flame/render.rb

Overview

Helper for render functionality

Instance Method Summary collapse

Instance Method Details

#view(path, options = {}) ⇒ Object Also known as: render



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/flame/render.rb', line 8

def view(path, options = {})
	## Take options for rendering
	scope = options.delete(:scope) || self
	layout = options.delete(:layout) || 'layout.*'
	## And get the rest variables to locals
	locals = options.merge(options.delete(:locals) || {})
	## Find filename
	filename = find_file(path)
	## Compile Tilt to instance hash
	@tilts ||= {}
	@tilts[filename] ||= Tilt.new(filename)
	## Render Tilt from instance hash with new options
	layout_render layout, @tilts[filename].render(scope, locals)
end