[Catalyst] :Template() Attribute

Leo Cacciari leo.cacciari at gmail.com
Fri Jun 15 16:15:39 GMT 2007


Il giorno ven, 15/06/2007 alle 09.58 -0400, Christopher H. Laco ha
scritto:
> Bill Moseley wrote:
> > On Fri, Jun 15, 2007 at 09:36:33AM -0400, Christopher H. Laco wrote:
> >> 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}.
> > 
> > So you would use:
> > 
> >     sub edit : Local : Template( 'edit.tt' ) {
> >         my ( $self, $c ) = @_
> >         ...
> >     }
> > 
> > instead of:
> > 
> >     sub edit : Local {
> >         my ( $self, $c ) = @_
> >         $c->stash->{template} = 'edit.tt';
> >         ...
> >     }
> > 
> > Or leaving it off and let View:TT create the template name
> > automatically from the action?
> > 
> > 
> 
> Yes. You can use both. Setting stash template always overrides the
> default Template() attribute for that current action via ||=

Putting it in another way, it would be the view side to Path, overriding
the default which maps action /foo/bar/foobar to method
MyApp::Controller::Foo:Bar::foobar and the latter to template
foo/bar/foobar... Yes, I like it :)

-- 
Leo "TheHobbit" Cacciari

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio
	firmata digitalmente
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070615/ad41377e/attachment-0001.pgp


More information about the Catalyst mailing list