[Catalyst] Wiki docs on serving static content

samwyse samwyse at gmail.com
Wed Jul 6 00:14:23 CEST 2005


On 7/5/05, Andy Grundman <andy at hybridized.org> wrote:

> If you like, you can use the dev.catalyst.perl.org Wiki for working on
> these kinds of documents.  I've already written one with details on how
> to properly serve static content, which will eventually make its way
> into the proper Tutorial.
> 
> http://dev.catalyst.perl.org/wiki

I note the following:

> My end methods usually look like this:
> 
> sub end : Global {
>     my ( $self, $c ) = @_;
> 
>     $c->forward( 'MyApp::V::TT' ) 
>         unless ( $c->res->body || !$c->stash->{template} );
> }
> 
> This code will only forward control to the view if a template has been 
> previously defined by a controller and if there is not already data in 
> $c->res->body. 

The first time that I saw this code a week or so ago, it took me a
minute to figure out just what was going on.  Seeing it again, I had
the same problem but this time I had some docs to fall back on. 
However, I can't help but notice that the docs describe things
differently from the code.  I'd suggest using the following which
exactly matches the description:

sub end : Global {
    my ( $self, $c ) = @_;

    $c->forward( 'MyApp::V::TT' ) 
        if ( $c->stash->{template} && !$c->res->body );
}



More information about the Catalyst mailing list