Sha256: f0696726284e8dc966cf98bf527748ed0c5ec11b52e218af9d1df15a8791eb11

Contents?: true

Size: 587 Bytes

Versions: 23

Compression:

Stored size: 587 Bytes

Contents

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

23 entries across 23 versions & 1 rubygems

Version Path
citygrid_api-0.0.28 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.27 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.26 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.25 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.24 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.23 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.22 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.21 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.20 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.19 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.18 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.17 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.16 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.15 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.14 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.13 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.12 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.11 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.10 lib/dashboard/sinatra_partial.rb
citygrid_api-0.0.9 lib/dashboard/sinatra_partial.rb