public
Description: A Rails plugin for mixing action-specific helper modules into your view
Homepage:
Clone URL: git://github.com/duelinmarkers/actionhelper.git
actionhelper / README
100644 52 lines (36 sloc) 1.468 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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