[Catalyst] :Template() Attribute

Bill Moseley moseley at hank.org
Mon Jun 18 15:20:16 GMT 2007


On Mon, Jun 18, 2007 at 09:28:36AM +0000, Zbigniew Lukasiak wrote:
> When we are at this View refactoring.  When changing the template you
> need to put the whole path on stash ( $c->stash( template =
> template_path/template.tt) ).  What I would propose is that the view
> automatically used the $c->action->namespace as the template_path - so
> that you would not need to specify the full path - only the template
> name.

Do you mean instead of $c->action->reverse like C::V::TT does now?
That is, so you always have to specify the template name?

This is what I currently do in my TT view:


sub template_name {
    my ( $self, $c ) = @_;

    return $c->stash->{template} if $c->stash->{template};

    my $extension = $self->config->{TEMPLATE_EXTENSION} || '.tt';

    my $template_suffix = delete $c->stash->{template_suffix} || q'';

    my $name
        = $c->stash->{template_action}
        ? $c->action->namespace . '/' . $c->stash->{template_action}
        : $c->action->reverse;

    return $name . $template_suffix . $extension;
}

So, in my case, is setting the template_action stash what you are describing?


I'm wondering how generic setting the template name can be.  Do
different templating tools use similar template names, or is this
mostly for TT?

I almost always tweak the template paths, too.  Sometimes it's for
skinning/branding or it's for I18N (e.g. root/templates/<language tag>/).


-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list