summaryrefslogtreecommitdiff
path: root/IkiWiki/Setup/Yaml.pm
blob: ba9192faf6f29ceb4fbb1f4a944de4b41bce3bd6 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Setup::Yaml;
  3. use warnings;
  4. use strict;
  5. use IkiWiki;
  6. use YAML;
  7. sub loaddump ($$) {
  8. my $class=shift;
  9. my $content=shift;
  10. IkiWiki::Setup::merge(Load($content));
  11. }
  12. sub gendump ($@) {
  13. my $class=shift;
  14. "# IkiWiki::Setup::Yaml - YAML formatted setup file",
  15. "#",
  16. (map { "# $_" } @_),
  17. "#",
  18. IkiWiki::Setup::commented_dump(\&dumpline, "")
  19. }
  20. sub dumpline ($$$$) {
  21. my $key=shift;
  22. my $value=shift;
  23. my $type=shift;
  24. my $prefix=shift;
  25. $YAML::UseHeader=0;
  26. my $dump=Dump({$key => $value});
  27. chomp $dump;
  28. if (length $prefix) {
  29. $dump=join("", map { $prefix.$_ } split(/\n/, $dump));
  30. }
  31. return $dump;
  32. }
  33. 1