This project is archived and is in readonly mode.
Refactoring ActionView::Partials
Reported by Ryan Bates | August 22nd, 2008 @ 01:04 AM
I saw some potential refactorings for ActionView::Partials to remove some duplication and clean things up. Attached is a patch.
Here's an overview of what I did.
render_partial
andrender_partial_collection
now take option hashes to simplify their argument list.render_partial
is the gateway to all partial rendering, this simplifies the Base render methods- split up rendering into multiple methods to handle the various object types: array, form, string, and other objects. These methods call each other to stay dry.
- the counter is now internally stored in
local_assigns
as "collection_counter" to simplify rendering of collections. I'm not entirely happy with moving this logic into Renderable#compile, but I couldn't think of a cleaner solution.
Let me know what you think.
Comments and changes to this ticket
-
josh August 22nd, 2008 @ 01:52 AM
- State changed from new to wontfix
- Assigned user set to josh
- Milestone cleared.
I don't like
- I'm against adding more private methods to the view context. It would be better to push that logic into RenderablePartial and break it up if possible.
- The Renderable#compile! method should have no logic concerning partials. I'd override compile! in RenderablePartial to add extra behavior.
- Why do you need to change the assertion in test_render_partial_collection_without_as?
I do like
- Moving useful logic (from ActionController) into ActionView.
- The idea of cleaning up Partial logic in general ;)
-
josh August 22nd, 2008 @ 03:05 AM
Took some of your ideas and cleaned up a few others things. Gave you the cred though.
1129a24
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 830 Add :spacer option to render I added ticket #881 which does some refactoring to Action...
- 1014 render partial collection with inline spacer Plan is to deprecate spacer templates and move them to pl...