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.4.14 lib/runit-man/partials.rb
runit-man-2.4.12 lib/runit-man/partials.rb
runit-man-2.4.11 lib/runit-man/partials.rb
runit-man-2.4.10 lib/runit-man/partials.rb
runit-man-2.4.9 lib/runit-man/partials.rb
runit-man-2.4.8 lib/runit-man/partials.rb
runit-man-2.4.7 lib/runit-man/partials.rb
runit-man-2.4.6 lib/runit-man/partials.rb
runit-man-2.4.5 lib/runit-man/partials.rb
runit-man-2.4.4 lib/runit-man/partials.rb
runit-man-2.4.3 lib/runit-man/partials.rb
runit-man-2.4.2 lib/runit-man/partials.rb
runit-man-2.4.1 lib/runit-man/partials.rb
runit-man-2.4.1a1 lib/runit-man/partials.rb
runit-man-2.4.0 lib/runit-man/partials.rb
runit-man-2.4.0a2 lib/runit-man/partials.rb
runit-man-2.4.0a1 lib/runit-man/partials.rb
runit-man-2.3.21 lib/runit-man/partials.rb
runit-man-2.3.20 lib/runit-man/partials.rb
runit-man-2.3.19 lib/runit-man/partials.rb