Problem occurs where partial is rendered with explicit locals.
Subsequent rendering of that partial without those locals, or with
different locals, retains access to the previous keys (NOT values).
I've tracked the problem (if it is a problem) to
ActionView::Base.compile_template_source and the use of
@@template_args.
The reason I question whether it is a genuine problem is because maybe
this is known and accepted for performance reasons.
Although, I'm not sure it is particularly problematic, it can cause
unexpected behviour. Example of unexpected behaviour..
* I have two actions, both of which render(:partial => 'my_partial').
The first renders with some locals that my_partial depends upon.
* I visit the first action (that sets locals) and see the partial correctly.
* I visit the second action (that doesn't set locals) and see the
partial correctly. * Unexpected - It should break.
* Restarting the webserver (or running a separate test that doesn't
first call the action with the locals) confirms that the second
action/partial combo is broken.
I'm incredibly unfamiliar with the templating stuff and so have
restrained from submitting some tests, although I do have an example
of showing that access to locals (note, access not the values) are
persisted.
Any suggestions on what should be happening?
Cheers,
Chris
1. render :partial => 'blah', :locals => {:somevar => true}
2. render :partial => 'blah'
In the second call to the partial, "defined?(somevar)" will return
true...even tho it wasn't in the locals passed in the render..
I'd like to have optional locals on some of my partials.
The current behavior requires me to always pass the local :somevar.
Does this strike anyone else as an issue?
cheers
Andy
--
Posted via http://www.ruby-forum.com/.
Subscription: http://railsexpress.de/blog/xml/rss20/feed.xml