X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ffc99f5904934e6e7532bb8cfdebb44ad9ecd913..6d98c5290f2542552979e374d8e3dcbef51f31a6:/IkiWiki/Plugin/conditional.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index 6be52eaa6..e787424aa 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -7,9 +7,18 @@ use IkiWiki 2.00; use UNIVERSAL; sub import { #{{{ + hook(type => "getsetup", id => "conditional", call => \&getsetup); hook(type => "preprocess", id => "if", call => \&preprocess_if); } # }}} +sub getsetup { #{{{ + return + plugin => { + safe => 1, + rebuild => undef, + }, +} #}}} + sub preprocess_if (@) { #{{{ my %params=@_; @@ -24,8 +33,8 @@ sub preprocess_if (@) { #{{{ # An optimisation to avoid needless looping over every page # and adding of dependencies for simple uses of some of the # tests. - $params{test} =~ /^\s*\!?\s*(enabled|sourcepage|destpage|included)\((.*)\)\s*$/) { - add_depends($params{page}, "$params{test} and $params{page}"); + $params{test} =~ /^([\s\!()]*((enabled|sourcepage|destpage|included)\([^)]*\)|(and|or))[\s\!()]*)+$/) { + add_depends($params{page}, "($params{test}) and $params{page}"); $result=pagespec_match($params{page}, $params{test}, location => $params{page}, sourcepage => $params{page},