At the time being, filters are parsed entirely before any Ruby is
evaluated. That means that there are no variables to pass them at that
point. However, in the future, we'll probably add the ability for them
to be dealt with either then or when the Ruby is evaluated, depending on
whether or not they receive arguments. In that case, your syntax seems
like a good one to use.
- Nathan
Evgeny wrote:
> 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 <http://network.id>}" ... I want to to write something like
> this in Haml : (notice the { :id => network.id <http://network.id> }
> near the filter name, and the '#{id} in the filtered text)
>
> %span.name[network]= h(network.name <http://network.name>)
> :javascript{ :id => network.id <http://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
-~----------~----~----~----~------~----~------~--~---