Skip to content

Instantly share code, notes, and snippets.

@ingydotnet
Created October 3, 2011 08:37
Show Gist options
  • Save ingydotnet/1258705 to your computer and use it in GitHub Desktop.
Save ingydotnet/1258705 to your computer and use it in GitHub Desktop.
ingy@thinkingy:~$ cat foo.pl
use YAML::XS qw'LoadFile DumpFile';
use Hash::Merge 'merge';
use Template::Toolkit::Simple;
use IO::All;
my $stash = merge(
LoadFile('b.yml'),
LoadFile('a.yml'),
);
$stash = merge({title => 'Mr'}, $stash);
io('out')->print(
tt->data($stash)->render("c.tt")
);
ingy@thinkingy:~$ cat a.yml
first: Ingy
ingy@thinkingy:~$ cat b.yml
last: döt Net
ingy@thinkingy:~$ cat c.tt
Yo. I am [% title %] [% first %] [% last %].
ingy@thinkingy:~$ perl foo.pl; hexdump -C out
00000000 59 6f 2e 20 49 20 61 6d 20 4d 72 20 49 6e 67 79 |Yo. I am Mr Ingy|
00000010 20 64 c3 b6 74 20 4e 65 74 2e 0a 0a | d..t Net...|
0000001c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment