aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/testpagespec.pm
blob: 77fab497ee0e5abd8d88286d59fe9f4e0574db86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/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";
	}
	else {
		return "no match: $ret";
	}
} # }}}

1