helper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (-38)
- 3.1.0 (0)
- 3.2.1 (-1)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-14)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (4)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (-1)
- 7.1.3.4 (0)
- What's this?
helper(*args, &block)
public
Includes the given modules in the template class.
Modules can be specified in different ways. All of the following calls include FooHelper:
# Module, recommended. helper FooHelper # String/symbol without the "helper" suffix, camel or snake case. helper "Foo" helper :Foo helper "foo" helper :foo
The last two assume that "foo".camelize returns “Foo”.
When strings or symbols are passed, the method finds the actual module object using String#constantize. Therefore, if the module has not been yet loaded, it has to be autoloadable, which is normally the case.
Namespaces are supported. The following calls include +Foo::BarHelper+:
# Module, recommended. helper Foo::BarHelper # String/symbol without the "helper" suffix, camel or snake case. helper "Foo::Bar" helper :"Foo::Bar" helper "foo/bar" helper :"foo/bar"
The last two assume that "foo/bar".camelize returns “Foo::Bar”.
The method accepts a block too. If present, the block is evaluated in the context of the controller helper module. This simple call makes the wadus method available in templates of the enclosing controller:
helper do def wadus "wadus" end end
Furthermore, all the above styles can be mixed together:
helper FooHelper, "woo", "bar/baz" do def wadus "wadus" end end