Sha256: d29e759224ce82b84f70c4150a66ada2e5fc1a339964f76fabd5c728a42fdb57
Contents?: true
Size: 701 Bytes
Versions: 18
Compression:
Stored size: 701 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 << erubis(:"#{template}", options.merge(:layout => false, :locals => {template_array[-1].to_sym => member})) end.join("\n") else erubis(:"#{template}", options) end end end
Version data entries
18 entries across 18 versions & 1 rubygems