Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 54 additions & 0 deletions t/lists/hooks.t
Original file line number Diff line number Diff line change
@@ -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{
<specification>
<list name="list" iterator="tokens">
<param field="html" class="htmlx" op="hook"/>
</list>
</specification>
};

my $goodspec = q{<specification>
<list name="list" iterator="tokens">
<param name="html" class="htmlx" op="hook"/>
</list>
</specification>
};

my $iter = [
{ html => '<em>my test</em>' },
{ html => '<div>my test</div>'},
];

my $html = q{
<div class="list"><div class="htmlx">KEY</div></div>
};

{
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}";
}