Filters are handled at compile time, so it's a little tricky to access the runtime ActionView context. You'll either need to override the #compile method and generate code calling the method, or create a new ActionView::Base instance and use that. I'd suggest looking at the Haml::Filters code for examples.
On Fri, Jan 9, 2009 at 9:23 AM, Evgeny <[email protected]> wrote: > Hi, > I am trying to use a rails helper in a haml filter, is it possible somehow? > > Something like this maybe: > > module Haml::Filters::Javascript > def render_with_options(text,options) > content_for(:javascript) { > text.rstrip.gsub("\n", "\n ") > } > end > end > > Would love for some help, since right now it errors with > > undefined method `content_for' for Haml::Filters::Javascript:Module > > which is understandable ... do I need to include some kind of rails module > or something? > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
