--- trunk/lib/HTML.pm 2008/06/28 22:13:05 10
+++ trunk/lib/HTML.pm 2008/06/29 00:36:08 14
@@ -5,19 +5,34 @@
use Time::HiRes qw/time/;
use Data::Dump qw/dump/;
+use Carp qw/confess/;
use View;
-use Data::Dump qw/dump/;
-
warn "available templates = ",dump( Template::Declare->templates );
+our @javascript;
+
use Template::Declare;
use Template::Declare::Tags; # defaults to 'HTML'
Template::Declare->init( roots => ['HTML','View'], around_template => sub {
my ($orig, $path, $args, $code) = @_;
my $t = time;
html {
- head {}
+ head {
+ title { $path }
+ link {
+ { rel is 'stylesheet' }
+ { href is 'static/app.css' }
+ { type is 'text/css' }
+ { media is 'screen' }
+ };
+ foreach my $js ( @javascript ) {
+ script {
+ { type is 'text/javascript' }
+ { src is $js }
+ }
+ }
+ }
body {
$orig->();
}
@@ -26,7 +41,14 @@
});
sub view {
-# warn "## view",dump( @_ );
my $self = shift;
return Template::Declare->show( @_ );
}
+
+sub add_javascript {
+ my $self = shift;
+ my $js = shift or confess "no JavaScript path";
+# return unless -e $js; # FIXME
+ warn "Added javascript $js\n";
+ push @javascript, $js;
+}