Last active
January 8, 2016 12:59
-
-
Save jonathanstowe/f3513b8b75a3868c7f58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class XMLWriter { | |
has $!in = 0; | |
method FALLBACK($name, *@c, *%attrs) { | |
(temp $!in)++; | |
my Str $attrs = (%attrs.keys > 0 ?? ' ' !! '') ~ %attrs.kv.map( -> $k, $v { "$k=\"$v\"" }).join(' '); | |
"<$name$attrs>\n" ~ @c>>.indent($!in).join("\n") ~ (+@c ?? "\n" !! "") ~ "</$name>" | |
} | |
} | |
my $x = XMLWriter.new; | |
say $x.foo($x.bar($x.baz("stuff")), zub => "flurble", bumble => "rarr"); | |
# vim: expandtab shiftwidth=4 ft=perl6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment