summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/testpagespec.pm
blob: 4faef7be197a8b20362132521ae67de2976a3ad8 (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. error sprintf(gettext("%s parameter is required"), $param);
  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. else {
  23. return "no match: $ret";
  24. }
  25. } # }}}
  26. 1