summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/testpagespec.pm
blob: f9ec90d8791f8b5e6aa422ceb527fe272bfea9df (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 $param parameter is required]]";
  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