5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/broadway/sinatra/helpers/partial_helper.rb', line 5
def partial(template, options = {})
template = template.to_s.squeeze("/")
options.symbolize_keys!
options.merge!(:layout => false)
template_array = template.to_s.split('/')
template = "_#{template_array[-1]}"
local_template = File.join(request.env["PATH_INFO"][1..-1], template)
template = local_template if File.exists?(File.join("public", local_template) + ".haml")
template = template_array[0..-2].join('/') + "/#{template}"
if collection = options.delete(:collection) then
collection.inject([]) do |buffer, member|
buffer << haml(:"#{template}", options.merge(:layout =>
false, :locals => {template_array[-1].to_sym => member}))
end.join("\n")
else
haml(:"#{template}", options)
end
end
|