Never mind - the filter below is now working for me.  Not sure what I
changed, but not going to argue with it!  Hope it's of use to somebody
else.

-Dan

On Oct 4, 5:53 pm, Dan Walters <[EMAIL PROTECTED]> wrote:
> I make a lot of use of merb-jquery's 'jquery' helper, which just
> accumulates snippets of javascript to be output all at once, e.g., in
> a document ready event.
>
> To use it with haml, I generally need to do:
>
> - jquery do
>   :plain
>     $('#id').function();
>
> While not necessary for the simple case, any script that has
> indentation, etc., must be run through the plain filter or haml
> complains about nested indentation, etc.
>
> For aesthetics, I tried to create a custom filter that combines the
> helper call and the plain filter, so I can just do:
>
> :jquery
>   $('#id').function();
>
> Right now, the precompiled source output looks basically the same to
> me, but I'm not getting any output (nothing at all) when I use the
> custom filter.  The filter is defined as follows:
>
> module Haml
>   module Filters
>     module JQuery
>
>       include Base
>
>       def compile(precompiler, text)
>         precompiler.instance_eval do
>           return if options[:suppress_eval]
>           push_silent "jquery do"
>           push_script
> "find_and_preserve(#{unescape_interpolation(text)})", false
>           push_silent "end"
>         end
>       end
>
>     end
>   end
> end
>
> As best I can tell, the Engine.precompiled output is the same for both
> cases, so I'm not sure what I'm doing wrong.  Any ideas?
>
> Thanks,
> -Dan

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