refactor to remove template_params
authorJoey Hess <joey@kitenet.net>
Thu, 22 Apr 2010 19:58:06 +0000 (15:58 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 22 Apr 2010 19:58:06 +0000 (15:58 -0400)
template_file will be kept separate, since it needs to be memoized

IkiWiki.pm

index 1327e4db50495f0b2b02ba0ab08eb1b55445bec6..0aaf605694d9fc2a53cb5c527a3b2e38e11da506 100644 (file)
@@ -1664,23 +1664,8 @@ sub template_file ($) {
        return;
 }
 
-sub template_params (@) {
-       filter => sub {
-               my $text_ref = shift;
-               ${$text_ref} = decode_utf8(${$text_ref});
-       },
-       loop_context_vars => 1,
-       die_on_bad_params => 0,
-       @_,
-       no_includes => 1,
-}
-
 sub template ($;@) {
-       require HTML::Template;
-       return HTML::Template->new(template_params(
-               filename => template_file(shift),
-               @_
-       ));
+       template_depends(shift, undef, @_);
 }
 
 sub template_depends ($$;@) {
@@ -1693,10 +1678,17 @@ sub template_depends ($$;@) {
        my $filename=template_file($name);
 
        require HTML::Template;
-       return HTML::Template->new(template_params(
+       return HTML::Template->new(
+               filter => sub {
+                       my $text_ref = shift;
+                       ${$text_ref} = decode_utf8(${$text_ref});
+               },
+               loop_context_vars => 1,
+               die_on_bad_params => 0,
                filename => $filename,
-               @_
-       ));
+               @_,
+               no_includes => 1,
+       );
 }
 
 sub misctemplate ($$;@) {