X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/3a2dfb94cbe475faa16f0329ffc5e75f330d1afa..c5b02885e934e5a1f8c5a8753ed47eaf4cce8b9f:/IkiWiki/Render.pm diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index caec7f1f0..1449b8931 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -31,11 +31,9 @@ sub htmlize ($$) { #{{{ error("htmlization of $type not supported"); } - if (exists $hooks{sanitize}) { - foreach my $id (keys %{$hooks{sanitize}}) { - $content=$hooks{sanitize}{$id}{call}->($content); - } - } + run_hooks(sanitize => sub { + $content=shift->($content); + }); return $content; } #}}} @@ -206,15 +204,9 @@ sub genpage ($$$) { #{{{ styleurl => styleurl($page), ); - if (exists $hooks{pagetemplate}) { - foreach my $id (keys %{$hooks{pagetemplate}}) { - $hooks{pagetemplate}{$id}{call}->( - page => $page, - destpage => $page, - template => $template, - ); - } - } + run_hooks(pagetemplate => sub { + shift->(page => $page, destpage => $page, template => $template); + }); return $template->output; } #}}} @@ -268,14 +260,9 @@ sub filter ($$) { my $page=shift; my $content=shift; - if (exists $hooks{filter}) { - foreach my $id (keys %{$hooks{filter}}) { - $content=$hooks{filter}{$id}{call}->( - page => $page, - content => $content - ); - } - } + run_hooks(filter => sub { + $content=shift->(page => $page, content => $content); + }); return $content; } @@ -412,7 +399,8 @@ sub refresh () { #{{{ my $page=pagename($file); if (! exists $oldpagemtime{$page} || - mtime(srcfile($file)) > $oldpagemtime{$page}) { + mtime(srcfile($file)) > $oldpagemtime{$page} || + $forcerebuild{$page}) { debug("rendering $file"); render($file); $rendered{$file}=1; @@ -496,15 +484,11 @@ FILE: foreach my $file (@files) { } } - if (@del && exists $hooks{delete}) { - foreach my $id (keys %{$hooks{delete}}) { - $hooks{delete}{$id}{call}->(@del); - } + if (@del) { + run_hooks(delete => sub { shift->(@del) }); } - if (%rendered && exists $hooks{change}) { - foreach my $id (keys %{$hooks{change}}) { - $hooks{change}{$id}{call}->(keys %rendered); - } + if (%rendered) { + run_hooks(change => sub { shift->(keys %rendered) }); } } #}}}