marcus
2/11/2006 10:58:00 PM
Caleb Clausen skrev:
> On 2/11/06, marcus <m-lists@bristav.se> wrote:
>
> How about this instead:
>
> def outerscope
> vars={}
> innerscope(vars)
> p vars[:foo],vars[:bar],vars[:baz]
> end
>
> def innerscope(vars)
> vars[:foo]=vars[:bar]=vars[:baz]=1
> end
>
The problem is that ERB#result(binding) takes a binding so I need the
binding. The templates used in this case relies on Rails rules (member
variables in a controller are available in the ERB template) and I need
to create a binding containing everything from the controller scope (and
then add the new needed stuff from the model).
What about passing a block from outer scope and call it from inner scope
and pass in a Hash with variables from the inner scope, then loop over
the variables and add those as instance members (using instance_eval),
create the binding (inside the block) and then invoke ERB.result. Could
that work?
/Marcus