diff --git a/MANIFEST b/MANIFEST index 3c2e525..0482f6b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -123,6 +123,7 @@ t/lists/append.t t/lists/double-process.t t/lists/gh11.t t/lists/global-containers.t +t/lists/hooks.t t/lists/increments.t t/lists/limit.t t/lists/nested.t diff --git a/t/lists/hooks.t b/t/lists/hooks.t new file mode 100644 index 0000000..cff825e --- /dev/null +++ b/t/lists/hooks.t @@ -0,0 +1,54 @@ +# Test for op="hook" in params +use strict; +use warnings; + +use Test::More tests => 3; +use Template::Flute; + +my $badspec = q{ + + + + + +}; + +my $goodspec = q{ + + + + +}; + +my $iter = [ + { html => 'my test' }, + { html => '
my test
'}, + ]; + +my $html = q{ +
KEY
+}; + +{ + my $tf = Template::Flute->new(template => $html, + specification => $badspec, + values => { + tokens => $iter, + }, + ); + eval { $tf->process }; + ok "$@", "Crash when missing name in the param"; +} + + +{ + my $tf = Template::Flute->new(template => $html, + specification => $goodspec, + values => { + tokens => $iter, + }, + ); + my $out = $tf->process; + like $out, qr{\Q$iter->[0]->{html}\E}, "Found $iter->[0]->{html}"; + like $out, qr{\Q$iter->[1]->{html}\E}, "Found $iter->[1]->{html}"; +}