/[Frey]/trunk/lib/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/HTML.pm

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

revision 10 by dpavlin, Sat Jun 28 22:13:05 2008 UTC revision 14 by dpavlin, Sun Jun 29 00:36:08 2008 UTC
# Line 5  use warnings; Line 5  use warnings;
5    
6  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8    use Carp qw/confess/;
9  use View;  use View;
10    
 use Data::Dump qw/dump/;  
   
11  warn "available templates = ",dump( Template::Declare->templates );  warn "available templates = ",dump( Template::Declare->templates );
12    
13    our @javascript;
14    
15  use Template::Declare;  use Template::Declare;
16  use Template::Declare::Tags; # defaults to 'HTML'  use Template::Declare::Tags; # defaults to 'HTML'
17  Template::Declare->init( roots => ['HTML','View'], around_template => sub {  Template::Declare->init( roots => ['HTML','View'], around_template => sub {
18          my ($orig, $path, $args, $code) = @_;          my ($orig, $path, $args, $code) = @_;
19          my $t = time;          my $t = time;
20          html {          html {
21                  head {}                  head {
22                            title { $path }
23                            link {
24                                    { rel is 'stylesheet' }
25                                    { href is 'static/app.css' }
26                                    { type is 'text/css' }
27                                    { media is 'screen' }
28                            };
29                            foreach my $js ( @javascript ) {
30                                    script {
31                                            { type is 'text/javascript' }
32                                            { src is $js }
33                                    }
34                            }
35                    }
36                  body {                  body {
37                          $orig->();                          $orig->();
38                  }                  }
# Line 26  Template::Declare->init( roots => ['HTML Line 41  Template::Declare->init( roots => ['HTML
41  });  });
42    
43  sub view {  sub view {
 #       warn "## view",dump( @_ );  
44          my $self = shift;          my $self = shift;
45          return Template::Declare->show( @_ );          return Template::Declare->show( @_ );
46  }  }
47    
48    sub add_javascript {
49            my $self = shift;
50            my $js = shift or confess "no JavaScript path";
51    #       return unless -e $js; # FIXME
52            warn "Added javascript $js\n";
53            push @javascript, $js;
54    }

Legend:
Removed from v.10  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26