Sha256: d5a44731c4b229d609d4ef6e3d91e22460eedde4f61f836753d3bfa41dd9c564
Contents?: true
Size: 697 Bytes
Versions: 44
Compression:
Stored size: 697 Bytes
Contents
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb # and made a lot more robust by me module Sinatra::Partials def partial(template, *args) template_array = template.to_s.split('/') template = template_array[0..-2].join('/') + "/_#{template_array[-1]}" options = args.last.is_a?(Hash) ? args.pop : {} options.merge!(:layout => false) 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 end
Version data entries
44 entries across 44 versions & 1 rubygems