summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2010-01-26 22:26:50 -0500
committerJoey Hess <joey@gnu.kitenet.net>2010-01-26 22:33:46 -0500
commit73253d6925ef84f9dd9e72919f8a136b93a0d277 (patch)
treed4abca819af56ebd9c8458d4fceb21b9742ed937 /IkiWiki/Plugin
parentf89b6f49d021762de8a260e92a4a3787cbf89b32 (diff)
template: Preprocess parameters before htmlizing.
Consider a template like: [[!template type=note text=""" [[!inline pages="*foo*"]] """]] The text parameter is htmlized before being passed into the template (in case the template wraps it in a <span> that prevents markdown from htmlizing it later). But, when markdown sees "*foo*", it turns that into <em>foo</em>. Later, when preprocessing the inline directive, that leads to suprising results. To fix this, I made template parameters be preprocessed (and filtered) before being htmlized. Note that I left in the preprocessing (and filtering) of the template output at the end. That's still relevant when the template itself contains preprocessor directives.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/template.pm19
1 files changed, 11 insertions, 8 deletions
diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
index b6097bb49..39d9667f9 100644
--- a/IkiWiki/Plugin/template.pm
+++ b/IkiWiki/Plugin/template.pm
@@ -25,6 +25,10 @@ sub getsetup () {
sub preprocess (@) {
my %params=@_;
+ # This needs to run even in scan mode, in order to process
+ # links and other metadata included via the template.
+ my $scan=! defined wantarray;
+
if (! exists $params{id}) {
error gettext("missing id parameter")
}
@@ -58,24 +62,23 @@ sub preprocess (@) {
$params{basename}=IkiWiki::basename($params{page});
foreach my $param (keys %params) {
+ my $value=IkiWiki::preprocess($params{page}, $params{destpage},
+ IkiWiki::filter($params{page}, $params{destpagea},
+ $params{$param}), $scan);
if ($template->query(name => $param)) {
$template->param($param =>
IkiWiki::htmlize($params{page}, $params{destpage},
pagetype($pagesources{$params{page}}),
- $params{$param}));
+ $value));
}
if ($template->query(name => "raw_$param")) {
- $template->param("raw_$param" => $params{$param});
+ $template->param("raw_$param" => $value);
}
}
- # This needs to run even in scan mode, in order to process
- # links and other metadata includes via the template.
- my $scan=! defined wantarray;
-
return IkiWiki::preprocess($params{page}, $params{destpage},
- IkiWiki::filter($params{page}, $params{destpage},
- $template->output), $scan);
+ IkiWiki::filter($params{page}, $params{destpage},
+ $template->output), $scan);
}
1