forked from twigphp/Twig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize batch function and add tests
- Loading branch information
Luiz “Felds” Liscia
committed
Feb 21, 2013
1 parent
15336c1
commit ccf3cd1
Showing
4 changed files
with
100 additions
and
31 deletions.
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 |
---|---|---|
@@ -1,37 +1,31 @@ | ||
--TEST-- | ||
"batch" filter | ||
--TEMPLATE-- | ||
<table> | ||
{% for row in items|batch(3, '') %} | ||
<tr> | ||
{% for row in items|batch(3) %} | ||
<div class=row> | ||
{% for column in row %} | ||
<td>{{ column }}</td> | ||
<div class=item>{{ column }}</div> | ||
{% endfor %} | ||
</tr> | ||
</div> | ||
{% endfor %} | ||
</table> | ||
--DATA-- | ||
return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')) | ||
--EXPECT-- | ||
<table> | ||
<tr> | ||
<td>a</td> | ||
<td>b</td> | ||
<td>c</td> | ||
</tr> | ||
<tr> | ||
<td>d</td> | ||
<td>e</td> | ||
<td>f</td> | ||
</tr> | ||
<tr> | ||
<td>g</td> | ||
<td>h</td> | ||
<td>i</td> | ||
</tr> | ||
<tr> | ||
<td>j</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
<div class=row> | ||
<div class=item>a</div> | ||
<div class=item>b</div> | ||
<div class=item>c</div> | ||
</div> | ||
<div class=row> | ||
<div class=item>d</div> | ||
<div class=item>e</div> | ||
<div class=item>f</div> | ||
</div> | ||
<div class=row> | ||
<div class=item>g</div> | ||
<div class=item>h</div> | ||
<div class=item>i</div> | ||
</div> | ||
<div class=row> | ||
<div class=item>j</div> | ||
</div> |
37 changes: 37 additions & 0 deletions
37
test/Twig/Tests/Fixtures/filters/batch_with_empty_fill.test
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,37 @@ | ||
--TEST-- | ||
"batch" filter | ||
--TEMPLATE-- | ||
<table> | ||
{% for row in items|batch(3, '') %} | ||
<tr> | ||
{% for column in row %} | ||
<td>{{ column }}</td> | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
--DATA-- | ||
return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')) | ||
--EXPECT-- | ||
<table> | ||
<tr> | ||
<td>a</td> | ||
<td>b</td> | ||
<td>c</td> | ||
</tr> | ||
<tr> | ||
<td>d</td> | ||
<td>e</td> | ||
<td>f</td> | ||
</tr> | ||
<tr> | ||
<td>g</td> | ||
<td>h</td> | ||
<td>i</td> | ||
</tr> | ||
<tr> | ||
<td>j</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> |
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,37 @@ | ||
--TEST-- | ||
"batch" filter | ||
--TEMPLATE-- | ||
<table> | ||
{% for row in items|batch(3, 'fill') %} | ||
<tr> | ||
{% for column in row %} | ||
<td>{{ column }}</td> | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
--DATA-- | ||
return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')) | ||
--EXPECT-- | ||
<table> | ||
<tr> | ||
<td>a</td> | ||
<td>b</td> | ||
<td>c</td> | ||
</tr> | ||
<tr> | ||
<td>d</td> | ||
<td>e</td> | ||
<td>f</td> | ||
</tr> | ||
<tr> | ||
<td>g</td> | ||
<td>h</td> | ||
<td>i</td> | ||
</tr> | ||
<tr> | ||
<td>j</td> | ||
<td>fill</td> | ||
<td>fill</td> | ||
</tr> | ||
</table> |