use strict;
use warnings;
use CGI;
use HTML::Template::Compiled 0.43;
my $offline = 1; # set to 1 if on development server
my $q = CGI->new;
print $q->header;
my $dir = '/www/cgi-bin/static';
my $rm = $q->param("rm")||"foo";
my $htc = HTML::Template::Compiled->new(
path => $dir,
scalarref => \<we are at runmode
foo
bar
EOM
# optional
# cache_dir => "$dir/cache",
);
my $foo = "rm=foo";
my $bar = "rm=bar";
my %p = (
runmode => $rm,
rm => {
foo => bless(\$foo, "Static::Link"),
bar => bless(\$bar, "Static::Link"),
},
);
$htc->param(%p);
print $htc->output;
if ($offline) {
# generate static page
$Static::Link::type = 'offline';
my $link = $p{rm}->{$rm};
my $file = "$link";
open my $fh, ">./static/htdocs/$file" or die $!;
print $fh $htc->output;
# update: set to cgi again
$Static::Link::type = 'cgi';
}