It can't. Filters are run at compile-time; they don't have access to the 
execution context. This won't be the case in 2.0, but for now it is.

I agree with other responders that the best solution would be a helper 
method. You don't need to define it in your Controller class; you could 
make a Helper module and include it in the eigenclass of the instance, 
or you could just add a method to Haml::Helpers, which is automatically 
included.

- Nathan

Bob Aman wrote:
>> Is it possible to dynamically add in a custom filter that would allow
>> me to get that :noautoindent functionality?
>>
>> Bob.
>>     
>
> Here's what I came up with:
>
> module Haml
>   module Filters
>     class OneLine
>       def initialize(text)
>         @text = text
>       end
>
>       def render
>         Haml::Engine.new(@text).render().gsub(/^\s+/, "").gsub(/[\r\n]
> +/, "")
>       end
>     end
>   end
> end
>
> Only problem:  I'm passing an execution context into the Haml engine,
> and I don't have a reference to it within the filter, which means that
> my execution context has changed anytime I use the filter.  Any idea
> how I can access the execution context from within that filter?
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
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