summaryrefslogtreecommitdiff
path: root/IkiWiki/Setup
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2010-03-19 15:50:59 -0400
committerJoey Hess <joey@gnu.kitenet.net>2010-03-19 15:52:53 -0400
commitbba513a3e52170dc06b545a44f2d859ae4b757b5 (patch)
treeba9ad8132817c754539a70ee78e542731a89a87a /IkiWiki/Setup
parent19a794b4829c548a7f5b9dc22e22c24d7f28bad8 (diff)
Add support for setup files written in YAML.
Not the default. (Yet?)
Diffstat (limited to 'IkiWiki/Setup')
-rw-r--r--IkiWiki/Setup/Yaml.pm43
1 files changed, 43 insertions, 0 deletions
diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm
new file mode 100644
index 000000000..ba9192faf
--- /dev/null
+++ b/IkiWiki/Setup/Yaml.pm
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+package IkiWiki::Setup::Yaml;
+
+use warnings;
+use strict;
+use IkiWiki;
+use YAML;
+
+sub loaddump ($$) {
+ my $class=shift;
+ my $content=shift;
+
+ IkiWiki::Setup::merge(Load($content));
+}
+
+sub gendump ($@) {
+ my $class=shift;
+
+ "# IkiWiki::Setup::Yaml - YAML formatted setup file",
+ "#",
+ (map { "# $_" } @_),
+ "#",
+ IkiWiki::Setup::commented_dump(\&dumpline, "")
+}
+
+
+sub dumpline ($$$$) {
+ my $key=shift;
+ my $value=shift;
+ my $type=shift;
+ my $prefix=shift;
+
+ $YAML::UseHeader=0;
+ my $dump=Dump({$key => $value});
+ chomp $dump;
+ if (length $prefix) {
+ $dump=join("", map { $prefix.$_ } split(/\n/, $dump));
+ }
+ return $dump;
+}
+
+1