]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/testpagespec.pm
Call srcfile() with nothrow, as clearly intended.
[git.ikiwiki.info.git] / IkiWiki / Plugin / testpagespec.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::testpagespec;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9         hook(type => "getsetup", id => "testpagespec", call => \&getsetup);
10         hook(type => "preprocess", id => "testpagespec", call => \&preprocess);
11 }
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => undef,
18                 },
19 }
21 sub preprocess (@) {
22         my %params=@_;
23         
24         foreach my $param (qw{match pagespec}) {
25                 if (! exists $params{$param}) {
26                         error sprintf(gettext("%s parameter is required"), $param);
27                 }
28         }
30         add_depends($params{page}, $params{pagespec});
31         
32         my $ret=pagespec_match($params{match}, $params{pagespec}, 
33                         location => $params{page});
34         if ($ret) {
35                 return "match: $ret";
36         }
37         else {
38                 return "no match: $ret";
39         }
40 }
42 1