#!/usr/bin/env perl use strict; use warnings; use lib 't/lib'; use Test::More; use Test::Handlebars; use Text::Xslate 'mark_raw'; render_ok( { helpers => { fullName => sub { my ($context, $person) = @_; return $person->{firstName} . ' ' . $person->{lastName}; }, }, }, <<'TEMPLATE',

By {{fullName author}}

{{body}}

Comments

{{#each comments}}

By {{fullName author}}

{{body}}
{{/each}}
TEMPLATE { author => { firstName => "Alan", lastName => "Johnson" }, body => "I Love Handlebars", comments => [ { author => { firstName => "Yehuda", lastName => "Katz" }, body => "Me too!" }, ], }, <<'RENDERED',

By Alan Johnson

I Love Handlebars

Comments

By Yehuda Katz

Me too!
RENDERED "example" ); render_ok( { helpers => { agree_button => sub { my ($context) = @_; return mark_raw( "" ); }, }, }, <<'TEMPLATE', TEMPLATE { items => [ { name => "Handlebars", emotion => "love" }, { name => "Mustache", emotion => "enjoy" }, { name => "Ember", emotion => "want to learn" }, ], }, <<'RENDERED', RENDERED "example" ); done_testing;