[Catalyst] template design issue: varibales stand-alone components

Andrew Rodland arodland at comcast.net
Wed Feb 4 23:45:43 GMT 2009


On Wednesday 04 February 2009 05:25:41 pm Gene Selkov wrote:
> On Wed, 4 Feb 2009, J. Shirley wrote:
> > The Catalyst method is quite simple, since it tries to adhere to the
> > MVC design patterns.
> >
> > You would not set the variable in your templates, instead in the
> > controller.
> >
> > sub action_name : Local {
> >    my ( $self, $c ) = @_;
> >   $c->stash->{surname} = $c->model('LDAP')->get_ldap_surname($id);
> > }
> >
> > Then your template gets 'surname' and you can just do:
> >
> > Hello <% $surname %>!
>
> I understood as much. The problem I am grappling with is the complexity of
> the web pages I have to present, with many different states and
> transitions. There is no way I can code for that with a single template.
>
There's no "single template" implied. By default you're probably going to have 
a template per-action, though that's completely up to you, and TT provides 
tools such as WRAPPER, INCLUDE, and BLOCK to let you organize and reuse your 
code. I'd suggest spending a little time with the Template::Manual as well as 
having a look at some real-life Catalyst apps.

Andrew





More information about the Catalyst mailing list