FAQ
Hi

I seem to remember reading on the list someone talking about "best practic"
for this being that the dir structure of templates mirrors the that of the
actions that they go with.

But I don't find the post back by searching. Am I right? I don't see any
obvious advantage ... unless you have actions of same names under different
controllers, which I'd probably try to avoid.

and what about common included tenplates and so on? any big reason not to
lump 'em all into one directory?

cheers

D

--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060420/ff054ec1/attachment.htm

Search Discussions

  • Bill Moseley at Apr 19, 2006 at 11:57 pm

    On Thu, Apr 20, 2006 at 01:20:09AM +0200, Daniel McBrearty wrote:
    I seem to remember reading on the list someone talking about "best practic"
    for this being that the dir structure of templates mirrors the that of the
    actions that they go with.
    Then you don't have to set $c->stash->{template} for every action.

    I use a custom TT view, and I have:

    $c->stash->{template} ||= $self->template_name($c);


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

    my $extension = $self->config->{TEMPLATE_EXTENSION} || '.tt';
    my $template_suffix = delete $c->stash->{template_suffix} || '';
    return $c->action->reverse . $template_suffix . $extension;
    }

    But I don't find the post back by searching. Am I right? I don't see any
    obvious advantage ... unless you have actions of same names under different
    controllers, which I'd probably try to avoid.
    I have "list" "view" "edit" in many different controllers. Seems
    very likely that action names would be the same.
    and what about common included tenplates and so on? any big reason not to
    lump 'em all into one directory?
    I have an "include" directory, but then have sub-directories within
    there. I also have a "page" directory that holds header, footer,
    wrapper, and layout templates. I have an "email" template that holds
    templates for emails, and those also mirror the controller layout.
    And so on.


    --
    Bill Moseley
    moseley at hank.org
  • Daniel McBrearty at Apr 20, 2006 at 12:15 am
    gotcha. thanks. Didn't realise that the template could be found
    automatically.

    I use a custom TT view, and I have:

    $c->stash->{template} ||= $self->template_name($c);


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

    my $extension = $self->config->{TEMPLATE_EXTENSION} || '.tt';
    my $template_suffix = delete $c->stash->{template_suffix} || '';
    return $c->action->reverse . $template_suffix . $extension;
    }
    pardon my higgerance ... how does this work? where does the custom view
    live? (maybe there's a bit of TT manual I still need to look at ... ?) - (or
    is it really simple and time I went to sleep ;)

    thanks for the explanation. nice.

    --
    Daniel McBrearty
    email : danielmcbrearty at gmail.com
    www.engoi.com : the multi - language vocab trainer
    BTW : 0873928131
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060420/10dd5ba8/attachment.htm

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedApr 19, '06 at 11:20p
activeApr 20, '06 at 12:15a
posts3
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Daniel McBrearty: 2 posts Bill Moseley: 1 post

People

Translate

site design / logo © 2021 Grokbase