From cbb3218db762341a1eafbf2892cb100755772f78 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Feb 2014 21:10:43 +0000 Subject: add readtemplate hook --- IkiWiki.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index e5da04a3b..5e17c4a73 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -2021,11 +2021,19 @@ sub template_depends ($$;@) { if (defined $page && defined $tpage) { add_depends($page, $tpage); } - + my @opts=( filter => sub { my $text_ref = shift; ${$text_ref} = decode_utf8(${$text_ref}); + run_hooks(readtemplate => sub { + ${$text_ref} = shift->( + id => $name, + page => $tpage, + content => ${$text_ref}, + untrusted => $untrusted, + ); + }); }, loop_context_vars => 1, die_on_bad_params => 0, -- cgit v1.2.3 From 7672014582a994624503399a1f50e855c4fc9ca7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Feb 2014 22:45:29 +0000 Subject: Add templatebody plugin and directive, and enable it by default Also add a regression test for templatebody. --- IkiWiki.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 5e17c4a73..d8cfc31cc 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -152,7 +152,8 @@ sub getsetup () { type => "internal", default => [qw{mdwn link inline meta htmlscrubber passwordauth openid signinedit lockedit conditional - recentchanges parentlinks editpage}], + recentchanges parentlinks editpage + templatebody}], description => "plugins to enable by default", safe => 0, rebuild => 1, -- cgit v1.2.3 From a9fc30b19cfb68c1bd326e0088a677fc87c7dca5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Mar 2014 10:11:04 +0000 Subject: Track whether we're in the scan or render phase In the scan phase, it's too early to match pagespecs or sort pages; in the render phase, both of those are OK. It would be possible to add phases later, renumbering them if necessary to maintain numerical order. --- IkiWiki.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'IkiWiki.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index d8cfc31cc..9511c8303 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -14,7 +14,7 @@ use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %delpagesources %destsources %depends %depends_simple @mass_depends %hooks %forcerebuild %loaded_plugins %typedlinks - %oldtypedlinks %autofiles @underlayfiles $lastrev}; + %oldtypedlinks %autofiles @underlayfiles $lastrev $phase}; use Exporter q{import}; our @EXPORT = qw(hook debug error htmlpage template template_depends @@ -34,6 +34,11 @@ our $DEPEND_CONTENT=1; our $DEPEND_PRESENCE=2; our $DEPEND_LINKS=4; +# Phases of processing. +sub PHASE_SCAN () { 0 } +sub PHASE_RENDER () { 1 } +$phase = PHASE_SCAN; + # Optimisation. use Memoize; memoize("abs2rel"); -- cgit v1.2.3