package CGI::Kwiki::Template; use base 'CGI::Kwiki', 'CGI::Kwiki::Privacy'; $VERSION = '0.18'; use strict; CGI::Kwiki->rebuild if @ARGV and $ARGV[0] eq '--rebuild'; sub directory { 'template' } sub suffix { my ($self, $file) = @_; $file =~ /README/ ? '' : '.html'; } sub process { my ($self, $template, %vars) = @_; my @vars = ( $self->config->all, $self->cgi->all, $self->prefs->all, $self->driver->metadata->all, $self->all, %vars, ); my @templates = ref $template ? @$template : $template; return join '', map { $self->render($self->read_template($_), @vars) } @templates; } sub read_template { my ($self, $template) = @_; my $template_file = -f "local/template/$template.html" ? "local/template/$template.html" : "template/$template.html"; open TEMPLATE, $template_file or die "Can't open $template_file for input\n"; binmode(TEMPLATE, ':utf8') if $self->use_utf8; my $template_text = do {local $/;