Module: Sinatra::Partials
- Included in:
- Helpers
- Defined in:
- lib/runit-man/partials.rb
Overview
stolen from github.com/cschneid/irclogger/blob/master/lib/partials.rb
and made a lot more robust by me
Instance Method Summary collapse
Instance Method Details
#partial(template, *args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/runit-man/partials.rb', line 4 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 |