/[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 27 by dpavlin, Sun Jun 29 20:11:27 2008 UTC revision 39 by dpavlin, Mon Jun 30 20:02:10 2008 UTC
# Line 19  Frey::HTML - generate html pages Line 19  Frey::HTML - generate html pages
19    
20  our @view_classes = qw(  our @view_classes = qw(
21          Frey::View          Frey::View
         Frey::REST  
22          Strix::View          Strix::View
23  );  );
24    
# Line 39  our $debug = 0; Line 38  our $debug = 0;
38    
39  use Template::Declare;  use Template::Declare;
40  use Template::Declare::Tags; # defaults to 'HTML'  use Template::Declare::Tags; # defaults to 'HTML'
41    
42  Template::Declare->init( roots => \@view_classes, around_template => sub {  Template::Declare->init( roots => \@view_classes, around_template => sub {
43          my ($orig, $path, $args, $code) = @_;          my ($orig, $path, $args, $code) = @_;
44            my $from = (caller(1))[3];
45            my $package = __PACKAGE__;
46            if ( $from !~ m/$package/ ) {
47                    warn "SKIP around_template for $path from $from\n";
48                    return $orig->();
49            } else {
50                    warn "WRAP around_temolate for $path from $from\n";
51            }
52    
53          my $t = time;          my $t = time;
54          html {          html {
55                  head {                  head {
# Line 56  Template::Declare->init( roots => \@view Line 65  Template::Declare->init( roots => \@view
65                                          { type is 'text/javascript' }                                          { type is 'text/javascript' }
66                                          { src is "/$js" }                                          { src is "/$js" }
67                                  }                                  }
68                          }                          };
69                  }                  }
70                  body {                  body {
71                          $orig->();                          $orig->();
# Line 74  Wrap template into html page Line 83  Wrap template into html page
83  =cut  =cut
84    
85  sub page {  sub page {
86          my $self = shift;          my ( $self, $page, $req, $args ) = @_;
87          warn "## page ",dump($_[0],ref($_[1]),$_[2]),"\n";          warn "## buffer_stack ",dump( Template::Declare->buffer_stack );
88          my $page = eval { Template::Declare->show( @_ ) };          Template::Declare->buffer->clear; # XXX we need to manually do this!
89            warn "## page $page ",dump($args),"\n";
90            my $out = eval { Template::Declare->show( $page, $req, $args ) };
91          if ( $@ ) {          if ( $@ ) {
92                  carp "ERROR: $@";                  carp "ERROR: $@";
93                  $page = Template::Declare->show( 'error', $_[1], "page" . dump($_[0], ref($_[1])) . "\n$@" );                  $out = Template::Declare->show( 'error', $req, "page $page " . dump($args) . ": $@" );
                 warn $page;  
94          }          }
95          return $page;          return $out;
96  }  }
97    
98  =head2 add_javascript  =head2 add_javascript
# Line 100  sub add_javascript { Line 110  sub add_javascript {
110          warn "Added javascript $js\n";          warn "Added javascript $js\n";
111          push @javascript, $js;          push @javascript, $js;
112  }  }
113    
114    1;

Legend:
Removed from v.27  
changed lines
  Added in v.39

  ViewVC Help
Powered by ViewVC 1.1.26