--- trunk/lib/Frey/HTML.pm 2008/06/30 20:02:14 41 +++ trunk/lib/Frey/HTML.pm 2008/06/30 20:02:16 42 @@ -42,21 +42,15 @@ our @javascript; our $debug = 0; -Template::Declare->init( roots => \@view_classes, around_template => sub { - my ($orig, $path, $args, $code) = @_; - my $from = (caller(1))[3]; - my $package = __PACKAGE__; - if ( $from !~ m/$package/ ) { - warn "SKIP around_template for $path from $from\n"; - return $orig->(); - } else { - warn "WRAP around_temolate for $path from $from\n"; - } +Template::Declare->init( roots => \@view_classes ); +sub page_template { + my ( $body ) = @_; + my $title = (caller(0))[3]; my $t = time; html { head { - title { $path } + title { $title } link { { rel is 'stylesheet' } { href is '/static/app.css' } @@ -70,12 +64,9 @@ } }; } - body { - $orig->(); - } + body { outs_raw $body } }; - warn "TEMPLATE $path ",dump($args),sprintf(" in %.4fs\n",time - $t) if $debug; -}); +}; =head2 page @@ -89,13 +80,13 @@ my ( $self, $page, $req, $args ) = @_; warn "## buffer_stack ",dump( Template::Declare->buffer_stack ); Template::Declare->buffer->clear; # XXX we need to manually do this! - warn "## page $page ",dump($args),"\n"; my $out = eval { Template::Declare->show( $page, $req, $args ) }; if ( $@ ) { carp "ERROR: $@"; $out = Template::Declare->show( 'error', $req, "page $page " . dump($args) . ": $@" ); } - return $out; + warn "## page $page ",dump($args)," ",length($out)," bytes\n"; + return scalar page_template($out); } =head2 add_javascript