8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/kaffe/render.rb', line 8
def render(template, options: {}, &block)
local = options.delete(:locals) || {}
views = options.delete(:views) || settings.views || "./views"
layout = options[:layout] || settings.layout || :layout
case template
when Symbol
path = nil
found = false
find_template(views, template, engine) do |file|
puts "testing #{file}"
if found = File.exists?(file)
path = file
break
end
end
raise "Could not find Template #{template}" unless found
t = templates.fetch(path) { Tilt.new path }
output = t.render(self, &block)
if layout
return render(engine, layout, layout: false) { output }
end
return output
end
end
|