Agile Web Development

Build it. Launch it. Love it.

SimplyPresentable

Save keystrokes and stay DRY with SimplyPresentable:

  <% present(foo).form do |f| %>
    <%= f.text_field :bar %>
  <% end %>

Instead of

  <% form_for(
       foo.new_record? ? {
         :url => 'http://example.com/foos',
         :html => { :method => 'post', :id => 'new_foo', :class => 'new_foo' }
       } :
       {
          :url => "http://example.com/foos/#{foo.id}",
          :html => { :method => 'put', :id => 'foo_1', :class => 'foo' }
        } :
      ) do |f| %>
    <%= f.text_field :bar %>
  <% end %>

SimplyPresentable is a plugin that introduces the idea of presenters to rails:

martinfowler.com/eaaDev/PresentationModel.html

Rails helpers are functional, and organized around controllers, not domain objects. Helper functions that are intended to operate on data types that span controllers end up being in the ApplicationHelper, or packaged into modules and included in other helpers.

SimplyPresentable attempts to fill the OO void left by a functional helper only approach to presentation:

  <%= link_to 'Show Foo', present(@foo).url %>

Vitals

Home http://simply_presentable.richcollins.net/
Repository http://richcollins.net/svn/simply_presentable/
License Rails' (MIT)
Tags Tag_red presenters views
Rating (2 votes)
Owner Rich Collins
Created 16 January 2007

Comments

  • Avatar
    16 January 2007

    I would love to get everyone's feedback on my plugin so I can keep making it better.

  • Avatar
    Xin
    30 March 2007

    Very interesting plugin. It sounds like it might be really useful, but I can't wrap my head around it.

    Would you be able to provide an easier to understand tutorial? I do not understand the 'instead of' code.

Add a comment