[Catalyst] automatically setting template name to the last detached action

Matt S Trout dbix-class at trout.me.uk
Sun May 21 21:04:40 CEST 2006


marcus wrote:
> $c->stash->{template} seems to automatically get set to the name of
> the requested action (using the TT view at least) -- a request for the
> url '/artist/save' sets {template} to 'artist/save'.
> 
> This is great, but I was wondering if there's a way to have {template}
> automatically get set to the last detached action (if there is one) as
> opposed to just the initially requested action.
> 
> For example, say a user submits to /artist/save, and there's invalid
> data so they get detached to /artist/edit, {template} would in the end
> be 'artist/edit'.
> 
> Infeasible?  Any plugins or suggested ways of going about this?

Just set the template in the edit action - if you want something simple 
that can be repeated around code, use

$c->stash(template => $c->stack->[-1]->reverse);

or so to get the action path.




More information about the Catalyst mailing list