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

Version Path
runit-man-2.0.9 lib/runit-man/partials.rb
runit-man-2.0.7 lib/runit-man/partials.rb
runit-man-2.0.6 lib/runit-man/partials.rb
runit-man-2.0.2 lib/runit-man/partials.rb
runit-man-2.0.1 lib/runit-man/partials.rb
runit-man-2.0.0 lib/runit-man/partials.rb
runit-man-1.11.6 lib/runit-man/partials.rb
runit-man-1.11.4 lib/runit-man/partials.rb
runit-man-1.11.3 lib/runit-man/partials.rb
runit-man-1.11.0 lib/runit-man/partials.rb
runit-man-1.10.3 lib/runit-man/partials.rb
runit-man-1.10.2 lib/runit-man/partials.rb
runit-man-1.10.1 lib/runit-man/partials.rb
runit-man-1.10.0 lib/runit-man/partials.rb
runit-man-1.9.8 lib/runit-man/partials.rb
runit-man-1.9.7 lib/runit-man/partials.rb
runit-man-1.9.6 lib/runit-man/partials.rb
runit-man-1.9.5 lib/runit-man/partials.rb