Skip to content

Commit

Permalink
+ collection presenter
Browse files Browse the repository at this point in the history
  • Loading branch information
Niko Dittmann committed Jun 9, 2008
1 parent 127deb4 commit 8a47c30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion amazombie/app/controllers/cart_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CartController < ApplicationController
include PresenterHelper

def self.example_methods
%w{books_each_partial description_line_in_model description_line_helper simple_presenter presenter_with_filter presenter_with_render_as}
%w{books_each_partial description_line_in_model description_line_helper simple_presenter presenter_with_filter presenter_with_render_as collection_presenter}
end

def index
Expand Down Expand Up @@ -34,6 +34,10 @@ def presenter_with_render_as
load_books_and_brains
end

def collection_presenter
load_books_and_brains
end


def current_user
# get the current user from the session
Expand Down
2 changes: 2 additions & 0 deletions amazombie/app/views/cart/collection_presenter.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- presenter = collection_presenter_for @items
= presenter.list :template_name => :cart_item, :separator => tag('hr')
5 changes: 3 additions & 2 deletions amazombie/app/views/presenters/collection/_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
List:
%ol.list
- collection.each do |item|
- presenter = presenter_for(item, self)
%li
= presenter.render_as(template_name)
= presenter.render_as(template_name)

= separator unless item == collection.last

0 comments on commit 8a47c30

Please sign in to comment.