Last night I made the mistake of wondering out loud on irc why we didn't have a :Template() attribute in controllers, since sometimes putting the template name in the stash hash just seems to hacky. Of course, wondering out loud on irc really means you've just volunteered yourself for a patch. :-)
The concept is easy, add :Template() to a controller method. Catalyst
automatically stoes that in the action->attributes. Then 'something' has
to do stash->{template} ||= action->attributes->{Template}.
The sticking point seems to be where should that line of code go?
OPTION #1: RenderView
----------------------------------------------
PROS:
Template is used by all views without adding code to each view.
Switching views honors Template() without fear of the View not
implementing it.
CONS:
Not everyone uses RenderView. Forward calls to a view would not know
about Template(). Things like REST could call a View to render long
before RenderView is called. Now REST has to be tweaked in addition to
RenderView. This is essentially just like having to add code to all
Views. When something else comes along that renders pre RenderView, it
also has to implement the tweak.
Template()/{template} info doesn't really belong in RenderView. Some
views have no concept of templates.
OPTION #2: View::TT, View::Mason, View::**
----------------------------------------------
PROS:
Template() will be honored with the use of RenderView and the use of
forwarding to a view manually (like in REST or other controller code).
CONS:
This has to be implemented in each View::** package that wants to
support it.
IF one changes from a view the support it, to one that doesn't,
controllers go boom.
OPTION #3: Implement it in my code only
----------------------------------------------
PROS:
I don't break any Catalyst bits trying to commit changes. :-)
CONS:
Seems like this is something everyone could benefit from.
Thoughts?
-=Chris
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
