I like the idea of being able to render a collection in one line and I too find it a bit clunky to include the conditional and literal content for the blank condition alongside the 99% case.
+1 for :if_blank -Chris On Sep 12, 6:15 am, rouffj <[email protected]> wrote: > Thanks guys for your suggestions. I Think that i'll adopt :if_blank > option name. > > Thanks again. > > Anyone has other ideas ? > > On Sep 12, 4:33 am, Trek Glowacki <[email protected]> wrote: > > > :if_nil doesn't describe all cases. The collection could be not nil > > (e.g. an empty array) and you'd still want the blank slate to show. > > > I'd suggest something related to blankness since it's the "blank > > slate" and both [ ].blank? and nil.blank? return true. > > > render :partial => "post", :collection => @posts, :if_blank => "none" > > > -Trek > > > On Fri, Sep 11, 2009 at 8:05 PM, Jason King <[email protected]> wrote: > > > > I like the concept, not the name. Can I suggest something like: > > > > render :partial => "post", :collection => @posts, :if_nil => "no_post" > > > > ?? > > > > On Sep 11, 2009, at 2:20 PM, rouffj wrote: > > > >> Hi, > > > >> Until now with Rails when we would handle empty collections in apps, > > >> we had to code it like that : > > > >> <%# app/views/posts/index.erb %> > > >> <% if @posts.empty? %> > > >> <p>Sorry, there is no posts yet !</p> > > >> <% else %> > > >> <% render :partial => "post", :collection => @posts %> > > > >> <% end % > > > >> Now with my modest contribution we can handle it in one line in view : > > > >> <%# app/views/posts/index.erb %> > > >> <%= render :partial => "post", :collection => > > >> @posts, :default_template => "no_post" %> > > > >> <%# app/views/posts/_no_post.erb %> > > > >> <p>Sorry, there is no posts yet !</p > > > >> So we can implement Getting real notion called "The blank slate" more > > >> easily. > > > >> One of you can review my patch (to see if i forget something) or > > >> comment it ? > > > >> Thanks. > > > >> --- > > >> lighthouse ticket > > >> :https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3187 > > >> patch > > >> :https://rails.lighthouseapp.com/projects/8994/tickets/3187/a/266544/e... > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
