The Haml::Helpers module is automatically included in the object used as the
context in which Haml is rendered. In the case of Rails, this means the
ActionView::Base instance. This inclusion only happens when Haml begins
rendering; in the controller, it hasn't happened yet.

It is possible, although a little hacky, to include Haml::Helpers in
ActionView::Base manually. In addition to doing this, make sure you call the
#init_haml_helpers method before using any of the helpers.

On Tue, Mar 23, 2010 at 5:47 AM, seb <[email protected]> wrote:

> Hi,
>
> I'm trying to call a helper method form a controller. The helper
> method uses the Haml helper methods capture_haml, haml_tag, etc But
> I'm runnning into errors like: "undefined method 'capture_haml'" and
> so.
>
> Example:
>
> class FooController
>  def update
>    render :string => self.class.helpers.foobar_string
>  end
> end
>
> module FooHelper
>  def foobar_string
>    capture_haml do
>       haml_tag :h1, 'hello world'
>    end
>  end
> end
>
> Is there a way to make this work?
>
> Thanks, Seb
>
> --
> You received this message because you are subscribed to the Google Groups
> "Haml" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected] <haml%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/haml?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to