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

Version Path
runit-man-2.3.18 lib/runit-man/partials.rb
runit-man-2.3.17 lib/runit-man/partials.rb
runit-man-2.3.16 lib/runit-man/partials.rb
runit-man-2.3.15 lib/runit-man/partials.rb
runit-man-2.3.12 lib/runit-man/partials.rb
runit-man-2.3.11 lib/runit-man/partials.rb
runit-man-2.3.9 lib/runit-man/partials.rb
runit-man-2.3.8 lib/runit-man/partials.rb
runit-man-2.3.7 lib/runit-man/partials.rb
runit-man-2.3.6 lib/runit-man/partials.rb
runit-man-2.3.5 lib/runit-man/partials.rb
runit-man-2.3.4 lib/runit-man/partials.rb
runit-man-2.3.3 lib/runit-man/partials.rb
runit-man-2.3.2 lib/runit-man/partials.rb
runit-man-2.3.1 lib/runit-man/partials.rb
runit-man-2.2.9 lib/runit-man/partials.rb
runit-man-2.2.8 lib/runit-man/partials.rb
runit-man-2.2.7 lib/runit-man/partials.rb
runit-man-2.2.6 lib/runit-man/partials.rb
runit-man-2.2.5 lib/runit-man/partials.rb