/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (show annotations)
Sun Jun 29 00:36:08 2008 UTC (14 years, 7 months ago) by dpavlin
Original Path: trunk/lib/HTML.pm
File size: 1058 byte(s)
- HTML->add_javascript to include javascript in page
- put debug class around debug output
1 package HTML;
2
3 use strict;
4 use warnings;
5
6 use Time::HiRes qw/time/;
7 use Data::Dump qw/dump/;
8 use Carp qw/confess/;
9 use View;
10
11 warn "available templates = ",dump( Template::Declare->templates );
12
13 our @javascript;
14
15 use Template::Declare;
16 use Template::Declare::Tags; # defaults to 'HTML'
17 Template::Declare->init( roots => ['HTML','View'], around_template => sub {
18 my ($orig, $path, $args, $code) = @_;
19 my $t = time;
20 html {
21 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 {
37 $orig->();
38 }
39 }
40 warn "TEMPLATE $path ",dump($args),sprintf(" in %.4fs\n",time - $t);
41 });
42
43 sub view {
44 my $self = shift;
45 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 }

  ViewVC Help
Powered by ViewVC 1.1.26