-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Corion/for-limit-modified
For limit modified
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use strict; | ||
use warnings; | ||
use lib qw[../../lib ../../blib/lib]; | ||
use Test::More; # Requires 0.94 as noted in Build.PL | ||
use Template::Liquid; | ||
use Data::Dumper; | ||
plan tests => 2; | ||
|
||
my $template = Template::Liquid->parse(<<'TEMPLATE'); | ||
First: {% for post in posts limit:1 %}{{ post }}{% endfor %} | ||
--- | ||
{% for post in posts limit:10 %}{{post}},{% endfor %} | ||
TEMPLATE | ||
|
||
my @list = qw( 1 2 3 4 5 6 7 8 9 10 11 ); | ||
|
||
my $result = $template->render( posts => \@list ); | ||
|
||
is $result, << 'RESULT', "We render the expected list"; | ||
First: 1 | ||
--- | ||
1,2,3,4,5,6,7,8,9,10, | ||
RESULT | ||
|
||
# This is a half-truth. Of course, Template::Liquid is allowed to modify the | ||
# list passed in, but it should still contain the original number of elements | ||
# so other template parts can still access that. | ||
is 0+@list, 11, "The original list remains unmodified" | ||
or diag Dumper \@list; |