Skip to content

Instantly share code, notes, and snippets.

@christianchristensen
Created June 5, 2013 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianchristensen/5710773 to your computer and use it in GitHub Desktop.
Save christianchristensen/5710773 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Template::Mustache;
# https://github.com/pvande/Template-Mustache/blob/master/t/read_data_from_hashes.t
print Template::Mustache->render(
<DATA>,
{
1 => 'a, b',
sub => {
2 => 'c',
3 => 'd',
},
4 => 'e, f',
}
);
# https://github.com/pvande/Template-Mustache/blob/master/t/read_partials_from_partial_method.t
print Template::Mustache->render(
'[ {{> list1}}, {{> list2}} ]',
{},
sub {
return 'a, b, c' if $_[0] eq 'list1';
return 'd, e, f' if $_[0] eq 'list2';
}
);
__DATA__
[ {{1}}, {{#sub}}{{2}}, {{3}}{{/sub}}, {{4}} ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment