[Catalyst-dev] suggestion to augment the default view

Matt S Trout dbix-class at trout.me.uk
Wed Sep 6 15:00:03 CEST 2006


John Napiorkowski wrote:
> Hi,
> 
> Right now when you forward to a view without any
> parameters ($c->view) the default is to either use a
> config setting or to just forward to a single view if
> there is only one view in the list.  That's how it's
> documented although I find the behavior is that if it
> finds several views it seems to return the first one
> returned based on some internal sorting order.

Current proposal is to add a check on $c->stash->{current_view} before it 
looks for $c->config->{default_view}

If neither is present it should be an error, not "return first found"; this is 
a bug that we'll be fixing soon.

> I propose we augment this behavior to add some rules
> to how it matches when there are more than one view
> component.  This issue comes to me because I find that
> I tend to make a lot of custom views based on the
> controller action name.  I do this because I prefer to
> move the creation of objects for rendering to the
> response body to the View directory so that I can keep
> my controllers clean and focused on dispatching tasks.
> 
> The Template Toolkit view has a very sane approach to
> automatically look for a template based on the action
> name.  I'm guessing this is a defacto standard for a
> lot of people.  What I am thinking is that the
> $c->view should model it's default behavior in a
> similar way, that is if you $c->forward($c->view) it
> should forward to a view component that is patterned
> off the algorithm used by the TT view.
> 
> For example:
> 
> /C
>    feeds->all :Local
>    feeds->new :Local
>    feeds->popular :Local
> /V
>    /feeds
>       all.pm
>       new.pm
>       popular.pm
> 
> So if you called "/feeds/all" the default view would
> be /feeds/all.pm and so forth.

Interesting concept, but I wonder if it might not be better as part of 
RenderView than as part of the core?

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst-dev mailing list