[Rails] Re: Partials inside partials
Eric Anderson
eric at afaik.us
Mon Jan 3 20:40:16 GMT 2005
Eric Anderson wrote:
> Is there anyway to do this or does
> Rails only support a single level of partials? I have verified that the
> second level of partials is executed but the "bar" variable does not
> appear to be in the scope of that second level.
After looking at the partials code it doesn't appear possible. I was
thinking perhaps we could use Kernel.local_variables to pass all local
variables into the partial automatically but figured that would polute
the namespace too much. So instead I opted to change the the
render_collection_of_partials to be more like render_partials. I put a
optional argument on render_collection_of_partials which is a hash of
local assigns. This allows me to put the following in the parent partial:
<%=render_collection_of_partials 'baz', @more_recs, nil, 'bar' => bar%>
This way bar is in scope. If I get some time today I will try to make a
diff of it against the Rails "head" and create the unit testing for it
in case anybody wants the same functionality.
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://one.textdrive.com/pipermail/rails/attachments/20050103/4469eba2/signature.bin
More information about the Rails
mailing list