Subject: | Bug in each helper |
Date: | Wed, 16 Apr 2014 09:01:52 +0200 |
To: | bug-Text-Handlebars [...] rt.cpan.org |
From: | Jörg Prante <joergprante [...] gmail.com> |
Hi,
there is a bug in the each helper. It does not implement object
hierarchy access.
Best,
Jörg
my $handlebars = Text::Handlebars->new;
# this works
my $tmpl =<<EOT;
{{#each list}}
<li>
{{#each doc}}
<div>{{this}}</div>
<span>{{../../info}}</span>
{{/each}}
</li>
{{/each}}
EOT
print $handlebars->render_string($tmpl,
{
info => "hello world",
list => [
{ "doc" => [ "a","b","c"] }
]
} );
# this does not work
my $tmpl =<<EOT;
{{#each list}}
<li>
{{#each doc}}
<div>{{this}}</div>
{{each ../../info}}<span>{{this}}</span>{{/each}}
{{/each}}
</li>
{{/each}}
EOT
print $handlebars->render_string($tmpl,
{
info => [ "hello", "world" ],
list => [
{ "doc" => [ "a","b","c"] }
]
} );
1;