> Yeah, I just discovered that about 5 minutes ago.  I guess I'll just
> leave it as it is for now then.  But definitely, this is a feature
> request:  I'd like to have access to the scope object from within
> filters in the future.
>
> Bob.

This is the code I would have liked to be able to write:


module Haml
  module Filters
    class OneLine
      def initialize(text)
        @text = text
      end

      def render(scope = Object.new)
        return Haml::Engine.new(@text).render(
          scope).gsub(/^\s+/, "").gsub(/[\r\n]+/, "")
      end
    end
  end
end

It feels weird to have the Engine's render method signature be
different from the filter's render method signature.

I had even tried changing the close_filtered method in the Haml engine
like so:

if filter.instance_method(:render).arity == 0
  filtered = filter.new(@filter_buffer).render
else
  filtered = filter.new(@filter_buffer).render(@scope_object)
end

But as Nathan pointed out, that won't have quite the desired effect,
since @scope_object won't have been set at the time that
close_filtered actually gets called.


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