diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-05-09 00:31:49 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-05-09 00:31:49 +0000 |
commit | 127bceef5b4799e58cb068043e49ed16a3ec840d (patch) | |
tree | 0f1f82d37fb8fca14410578ed00892534ad2584c /IkiWiki | |
parent | e1c54fef3da56ad9bb94fc7e187a56106a59f8cb (diff) | |
download | ikiwiki-127bceef5b4799e58cb068043e49ed16a3ec840d.tar ikiwiki-127bceef5b4799e58cb068043e49ed16a3ec840d.tar.gz |
* Add all=no option to conditional, can be used to form conditionals that do
not need to examine every page in the wiki.
* Use this to simplify the goodstuff detection in the plugin template.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/conditional.pm | 16 | ||||
-rw-r--r-- | IkiWiki/Plugin/testpagespec.pm | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index a7ed6590e..6c14361f7 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -13,15 +13,19 @@ sub import { #{{{ sub preprocess_if (@) { #{{{ my %params=@_; - if (! exists $params{test} || ! exists $params{then}) { - return "[[if ".gettext('"test" and "then" parameters are required')."]]"; + foreach my $param (qw{test then}) { + if (! exists $params{$param}) { + return "[[if ".sprintf(gettext('%s parameter is required'), $param)."]]"; + } } my $result=0; - # An optimisation to avoid needless looping over every page - # and adding of dependencies for simple uses of some of the - # tests. - if ($params{test} =~ /^(enabled|sourcepage|destpage)\((.*)\)$/) { + if ((exists $params{all} && lc $params{all} eq "no") || + # An optimisation to avoid needless looping over every page + # and adding of dependencies for simple uses of some of the + # tests. + $params{test} =~ /^(enabled|sourcepage|destpage)\((.*)\)$/) { + add_depends($params{page}, "$params{test} and $params{page}"); $result=pagespec_match($params{page}, $params{test}, location => $params{page}, sourcepage => $params{page}, diff --git a/IkiWiki/Plugin/testpagespec.pm b/IkiWiki/Plugin/testpagespec.pm index 77fab497e..f9ec90d87 100644 --- a/IkiWiki/Plugin/testpagespec.pm +++ b/IkiWiki/Plugin/testpagespec.pm @@ -14,7 +14,7 @@ sub preprocess (@) { #{{{ foreach my $param (qw{match pagespec}) { if (! exists $params{$param}) { - return "[[testpagespec missing $param parameter]]"; + return "[[testpagespec $param parameter is required]]"; } } |