/[Frey]/trunk/lib/Frey/HTML.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/HTML.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by dpavlin, Mon Jun 30 20:02:12 2008 UTC revision 42 by dpavlin, Mon Jun 30 20:02:16 2008 UTC
# Line 42  warn "available templates = ",dump( Temp Line 42  warn "available templates = ",dump( Temp
42  our @javascript;  our @javascript;
43  our $debug = 0;  our $debug = 0;
44    
45  Template::Declare->init( roots => \@view_classes, around_template => sub {  Template::Declare->init( roots => \@view_classes );
46          my ($orig, $path, $args, $code) = @_;  sub page_template {
47          my $from = (caller(1))[3];          my ( $body ) = @_;
48          my $package = __PACKAGE__;          my $title = (caller(0))[3];
         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";  
         }  
49    
50          my $t = time;          my $t = time;
51          html {          html {
52                  head {                  head {
53                          title { $path }                          title { $title }
54                          link {                          link {
55                                  { rel is 'stylesheet' }                                  { rel is 'stylesheet' }
56                                  { href is '/static/app.css' }                                  { href is '/static/app.css' }
# Line 70  Template::Declare->init( roots => \@view Line 64  Template::Declare->init( roots => \@view
64                                  }                                  }
65                          };                          };
66                  }                  }
67                  body {                  body { outs_raw $body }
                         $orig->();  
                 }  
68          };          };
69          warn "TEMPLATE $path ",dump($args),sprintf(" in %.4fs\n",time - $t) if $debug;  };
 });  
70    
71  =head2 page  =head2 page
72    
# Line 89  sub page { Line 80  sub page {
80          my ( $self, $page, $req, $args ) = @_;          my ( $self, $page, $req, $args ) = @_;
81          warn "## buffer_stack ",dump( Template::Declare->buffer_stack );          warn "## buffer_stack ",dump( Template::Declare->buffer_stack );
82          Template::Declare->buffer->clear; # XXX we need to manually do this!          Template::Declare->buffer->clear; # XXX we need to manually do this!
         warn "## page $page ",dump($args),"\n";  
83          my $out = eval { Template::Declare->show( $page, $req, $args ) };          my $out = eval { Template::Declare->show( $page, $req, $args ) };
84          if ( $@ ) {          if ( $@ ) {
85                  carp "ERROR: $@";                  carp "ERROR: $@";
86                  $out = Template::Declare->show( 'error', $req, "page $page " . dump($args) . ": $@" );                  $out = Template::Declare->show( 'error', $req, "page $page " . dump($args) . ": $@" );
87          }          }
88          return $out;          warn "## page $page ",dump($args)," ",length($out)," bytes\n";
89            return scalar page_template($out);
90  }  }
91    
92  =head2 add_javascript  =head2 add_javascript

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26