Module: Sinatra::Partials
- Defined in:
- lib/mongojob/web/helpers.rb
Overview
Copied and adapted to HAML from gist.github.com/119874 - thanks!
Instance Method Summary collapse
Instance Method Details
#partial(template, *args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mongojob/web/helpers.rb', line 32 def partial(template, *args) template_array = template.to_s.split('/') template = template_array[0..-2].join('/') + "/_#{template_array[-1]}" = args.last.is_a?(Hash) ? args.pop : {} .merge!(:layout => false) if collection = .delete(:collection) then collection.inject([]) do |buffer, member| buffer << haml(:"#{template}", .merge(:layout => false, :locals => {template_array[-1].to_sym => member})) end.join("\n") else haml(:"#{template}", ) end end |