#!/usr/bin/env perl
use strict;
use warnings;
use lib 't/lib';
use Test::More;
use Test::Handlebars;
use Text::Xslate 'mark_raw';
{ local $TODO = "unimplemented";
render_ok(
{
function => {
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(
{
function => {
agree_button => sub {
my ($context) = @_;
return mark_raw(
""
);
},
},
},
<<'TEMPLATE',
{{#each items}}
{{agree_button}}
{{/each}}
TEMPLATE
{
items => [
{ name => "Handlebars", emotion => "love" },
{ name => "Mustache", emotion => "enjoy" },
{ name => "Ember", emotion => "want to learn" },
],
},
<<'RENDERED',