Saturday, September 29, 2007

Rails plugin: optional parameters for partial views

Just "published" my very first Ruby on Rails plugin today.

Been using it in a personal project of mine for awhile.

Basically, its optional parameters for partial views, to make it a bit more clean.

render :partial => 'post', :locals => { :post => @post}, :opts => { :show_comments => true }

<% if opts.with_default(:show_comments, false) %>
Yadda yadda
<% end %>

Not much code, but its a simple idiom I found myself repeating (a lot) so I wrapped it up into a plugin.

Arron's rails plugins

No comments: