blob: a0bb2ff3128e4f9a5d3853f5006aa0d76a074004 (
plain)
- #!/usr/bin/perl
- package IkiWiki::Plugin::testpagespec;
- use warnings;
- use strict;
- use IkiWiki 2.00;
- sub import { #{{{
- hook(type => "preprocess", id => "testpagespec", call => \&preprocess);
- } # }}}
- sub preprocess (@) { #{{{
- my %params=@_;
-
- foreach my $param (qw{match pagespec}) {
- if (! exists $params{$param}) {
- return "[[testpagespec missing $param parameter]]";
- }
- }
- add_depends($params{page}, $params{pagespec});
-
- my $ret=pagespec_match($params{match}, $params{pagespec},
- location => $params{page});
- if ($ret) {
- return "match: $ret";
- }
- elsif (! defined $ret) {
- return "match failed: $@";
- }
- else {
- return "no match: $ret";
- }
- } # }}}
- 1
|