Over the last couple weeks I've been working on a change that allows parts of a View to be accessed after composition. Up to this point, once a View was built you lost the ability to reference it's parts (e.g. containers/partials). No more!
Here are the related commits (the important ones anyway):
https://github.com/metabahn/pakyow/commit/0a198285e4add4d1d8c689450145b64be2cdcb76
https://github.com/metabahn/pakyow/commit/1c0227518ddd405deb1e178e2c00f68147b6144f
https://github.com/metabahn/pakyow/commit/e0c3dfc79c56861fb9a808cb7706b851fe527bf8
It's worth mentioning that all of this was made possible by the ViewComposer object inspired by Chris Hansen in this post. Here is some example usage:
# set presenter's view to partial 'foo' view = partial(:foo) # reduce view to container 'default' when finding scope container(:default).scope(:foo).attrs.style = 'background:red' # remove a container container(:side).remove # replace a partial when some other partial partial(:foo).replace(store.partial('/', :bar))
Take a look at lines 102-160 in presenter.rb if you want to get a better feel for this.
One thing I want to be clear about is that this change does not in any way violate the "perform up-front or at the last possible moment" aspect of Presenter. Since modifying a composition is the exception rather than the rule, all views are precomposed as they always have been. When a destructive change is made to one of the composed parts the composer will rebuild the view when necessary.
We retain all of the performance and gain some really nice features.
In closing, I wanted to mention that this is the final change for 0.8 final. The new homepage is ready to launch, and we're putting the final touches on the documentation.
Happy to entertain any questions or comments.
Bryan P.