$self->replace_content($name);
}
+my %page_cache;
+for (<tmpl/*>) {
+ my ($tmpl, $lang) = m,tmpl/(\w+)\.(\w+),;
+ my $builder = HTML::Seamstress->new;
+ $builder->ignore_unknown(0);
+ $page_cache{$tmpl, $lang} = $builder->parse_file($_);
+}
+
sub render {
my ($tmpl, $lang, %args) = @_;
$lang //= 'en';
sub _render {
my ($tmpl, $lang, %args) = @_;
- my $builder = HTML::Seamstress->new;
- $builder->ignore_unknown(0);
- my $tree = $builder->parse_file("tmpl/$tmpl.$lang");
+ my $tree = $page_cache{$tmpl, $lang}->clone or die "No such template/language combination: $tmpl/$lang\n";
$tree = $tree->guts unless $tmpl eq 'skel';
$tree->defmap(smap => \%args);
my $process = __PACKAGE__->can("process_$tmpl");
my @pb = map { @{$args{$_} // []} } qw/beginner easy medium hard/;
$tree->fclass('well')->iter3(\@pb, $iter);
}
+
+1;
+__END__