[Catalyst] :Template() Attribute

Christopher H. Laco claco at chrislaco.com
Fri Jun 15 14:58:06 GMT 2007


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} ||=3D action->attributes->{Template}.
> =

> So you would use:
> =

>     sub edit : Local : Template( 'edit.tt' ) {
>         my ( $self, $c ) =3D @_
>         ...
>     }
> =

> instead of:
> =

>     sub edit : Local {
>         my ( $self, $c ) =3D @_
>         $c->stash->{template} =3D '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 ||=3D

-=3DChris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070615/a3a8=
358e/signature.pgp


More information about the Catalyst mailing list