diff options
author | dakkar <dakkar@thenautilus.net> | 2013-05-17 21:07:38 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2013-05-17 21:07:38 +0100 |
commit | 6bbe2df38ad465ad0151c07397d7d85bf0e841dc (patch) | |
tree | 9c19cf05e4cb33c0cc7eeda5c3764d30e6444e52 /forecast-file.pl | |
parent | data spans (diff) | |
download | HomePanel-6bbe2df38ad465ad0151c07397d7d85bf0e841dc.tar.gz HomePanel-6bbe2df38ad465ad0151c07397d7d85bf0e841dc.tar.bz2 HomePanel-6bbe2df38ad465ad0151c07397d7d85bf0e841dc.zip |
rough template for output
Diffstat (limited to 'forecast-file.pl')
-rw-r--r-- | forecast-file.pl | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/forecast-file.pl b/forecast-file.pl index 950b7e0..990dfa9 100644 --- a/forecast-file.pl +++ b/forecast-file.pl @@ -4,15 +4,20 @@ use warnings; use 5.014; use WebService::ForecastIo::Response; use Path::Class; -use Data::Printer; +use Template; my $res = WebService::ForecastIo::Response->new(file($ARGV[0])->slurp); -p $res; +my $t = Template->new; +$t->process(\*DATA,{f=>$res}) + or die $t->error; -my $hourly_summary_spans = $res->hourly->spans_by_string('summary'); +__DATA__ +[% MACRO dtspan BLOCK -%] +<[% x.start_time.strftime('%H:%M%z') %] - [%x.stop_time.strftime('%H:%M%z') %]> [% x.value %] +[%- END -%] +Currently: [% f.currently.summary %] [% f.currently.temperature %]° +[% f.hourly.summary %] -p $hourly_summary_spans; +[% FOREACH x IN f.hourly.spans_by_string('summary'); dtspan(x=x); ' '; END %] +[% FOREACH x IN f.hourly.spans_by_number('temperature',2); dtspan(x=x); ' '; END %] -my $hourly_temp_spans = $res->hourly->spans_by_number('temperature',1); - -p $hourly_temp_spans; |