A Rails plugin for mixing action-specific helper modules into your view
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
tasks
README
Rakefile
init.rb
install.rb
uninstall.rb

README

ActionHelper
============

ActionHelper is a Rails plugin that allows you to create view helper modules 
for specific actions or templates, as opposed to the controller-wide helper 
facility Rails provides.


Example
=======

There are currently three ways to get action-specific helpers mixed in.

module SuperHawtnessHelper end
module ExampleSweetnessHelper end

class ExampleController < ActionController::Base
  include ActionHelper
  
  helper SuperHawtnessHelper, :only => :hawtness
  
  def hawtness
    # Only this action will get SuperHawtnessHelper since the #helper call 
    # above used the :only option.
  end
  
  def sweetness
    # This action will get ExampleSweetnessHelper because the name matches 
    # the controller name and action name concatenated.
  end
  
  def supercool; action_helper ExampleSweetnessHelper
    # This action will get ExampleSweetnessHelper because it just said so.
  end
end


TODO
====

* Allow an action to declare what helper(s) it wants by name in addition to 
  passing the module itself (same as Rails does).
* Experiment with keying off the template name rather than the action (to deal 
  with actions that might render alternate templates)
* Build up a master module for each action so we're not doing so many extends 
  on every request.
* Get things self-contained so specs (including controller specs) run without 
  a surrounding Rails app.


Copyright (c) 2008 John D. Hume, released under the MIT license