Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Text-Handlebars CPAN distribution.

Report information
The Basics
Id: 94792
Status: resolved
Priority: 0/
Queue: Text-Handlebars

People
Owner: Nobody in particular
Requestors: joergprante [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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;
Of course, it's use Text::Handlebars; my $handlebars = Text::Handlebars->new; 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"] } ] } ); and the error message is Text::Xslate::Syntax::Handlebars: Expected ';', but got '..', near each, while parsing templates (<string>:8) Jörg Am Mi 16. Apr 2014, 03:02:06, joergprante@gmail.com schrieb: Show quoted text
> 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;
Thanks, fixed in 0.04.