summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/testpagespec.pm
blob: a0bb2ff3128e4f9a5d3853f5006aa0d76a074004 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::testpagespec;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 2.00;
  6. sub import { #{{{
  7. hook(type => "preprocess", id => "testpagespec", call => \&preprocess);
  8. } # }}}
  9. sub preprocess (@) { #{{{
  10. my %params=@_;
  11. foreach my $param (qw{match pagespec}) {
  12. if (! exists $params{$param}) {
  13. return "[[testpagespec missing $param parameter]]";
  14. }
  15. }
  16. add_depends($params{page}, $params{pagespec});
  17. my $ret=pagespec_match($params{match}, $params{pagespec},
  18. location => $params{page});
  19. if ($ret) {
  20. return "match: $ret";
  21. }
  22. elsif (! defined $ret) {
  23. return "match failed: $@";
  24. }
  25. else {
  26. return "no match: $ret";
  27. }
  28. } # }}}
  29. 1