diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-01-12 20:48:19 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-01-12 20:48:19 +0000 |
commit | 8c8ce06a1b267a5c5d0b1a4f2b229b6d15e63b71 (patch) | |
tree | d829bc29734f5ae0abbe64728a1a5050cdc28347 /IkiWiki.pm | |
parent | b26b1d51ab4e71fb04674815c6b08f401ec22993 (diff) | |
download | ikiwiki-8c8ce06a1b267a5c5d0b1a4f2b229b6d15e63b71.tar ikiwiki-8c8ce06a1b267a5c5d0b1a4f2b229b6d15e63b71.tar.gz |
* Search in default location for templates as a fallback when templatedir is
pointed elsewhere, so that only modified templates need to be copied into
a templatedir. Based on work by JeremyReed.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r-- | IkiWiki.pm | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 43ef67e8c..8a3c81755 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -636,18 +636,35 @@ sub saveindex () { #{{{ close OUT; } #}}} +sub template_file ($) { #{{{ + my $template=shift; + + foreach my $dir ($config{templatedir}, "$installdir/share/ikiwiki/templates") { + return "$dir/$template" if -e "$dir/$template"; + } + return undef; +} #}}} + sub template_params (@) { #{{{ - my $filename=shift; - + my $filename=template_file(shift); + + if (! defined $filename) { + return if wantarray; + return ""; + } + require HTML::Template; - return filter => sub { + my @ret=( + filter => sub { my $text_ref = shift; $$text_ref=&Encode::decode_utf8($$text_ref); }, - filename => "$config{templatedir}/$filename", + filename => $filename, loop_context_vars => 1, die_on_bad_params => 0, - @_; + @_ + ); + return wantarray ? @ret : {@ret}; } #}}} sub template ($;@) { #{{{ |