Greetings Nathan, Hampton, Haml/Sass users, All ...

As far as I know - there is no way to use "external" (haml scope) variables
inside a filter, please correct me if I am wrong.

I wrote a really simple filter that "requires" me to have variables, and I
want to suggest a syntax that will look natural to all developers using
ruby.

My filter is "javascript", and the filter class is extremely simple, here is
the render filter method:
def render
  return <<-EOT
    <script type=\"text/javascript\">
    //<![CDATA[
    [EMAIL PROTECTED]
    //]]>
    </script>
  EOT
end

If only I could replace the '[EMAIL PROTECTED]' with '#{eval(@text)}', then I 
could
use variables that Haml passed to the filter. Or if for some reason I dont
like 'eval', I could also use gsub to replace all '#id' and '#{id}' with
just the value of 'id', which is perhaps less risky than having "eval"
sitting in the middle of a filter.

Only problem is, Haml does not pass any variables ... the idea I had was
just like "render :partial => 'foobar', :locals => { :id => network.id}" ...
I want to to write something like this in Haml :   (notice the { :id =>
network.id } near the filter name, and the '#{id} in the filtered text)

%span.name[network]= h(network.name)
:javascript{ :id => network.id }
  new Ajax.InPlaceEditor('network_#{id}',
'/networks/set_network_name/#{id}');

This will allow me to use #{id} inside the filter text, and then the filter
itself will evaluate the filter text again ... and #{id} will be available
to it.


Please comment!, and ask questions if any,

Regards,

- evgeny

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