Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1795 Traversable support for 'replace', 'merge' and 'sort' (…
…SpacePossum) This PR was merged into the 1.x branch. Discussion ---------- Traversable support for 'replace', 'merge' and 'sort' Add traversable support to: * replace * merge * sort Other changes: * Removes some not need checks * ~~Make unit test skip if it cannot write to cache because of the user running the test~~ * Tests added for traversable support * Doc updates Deprecating: I think the undocumented (and multibyte not supported) use of `replace(string, string)` can be removed in Twig 2.0. Adding MB support and documentation of the feature was turned down (#1618) However removing it is a BC break (#1445 (comment)) Commits ------- 2a17303 Mark test skipped if cannot write to cache directory.
- Loading branch information
Showing
7 changed files
with
70 additions
and
14 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
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
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,8 +1,12 @@ | ||
--TEST-- | ||
"replace" filter | ||
--TEMPLATE-- | ||
{{ "I like %this% and %that%."|replace({'%this%': "foo", '%that%': "bar"}) }} | ||
{{ "I liké %this% and %that%."|replace({'%this%': "foo", '%that%': "bar"}) }} | ||
{{ 'I like single replace operation only %that%'|replace({'%that%' : '%that%1'}) }} | ||
{{ 'I like %this% and %that%.'|replace(traversable) }} | ||
--DATA-- | ||
return array() | ||
return array('traversable' => new ArrayObject(array('%this%' => 'foo', '%that%' => 'bar'))) | ||
--EXPECT-- | ||
I liké foo and bar. | ||
I like single replace operation only %that%1 | ||
I like foo and bar. |
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,8 @@ | ||
--TEST-- | ||
Exception for invalid argument type in replace call | ||
--TEMPLATE-- | ||
{{ 'test %foo%'|replace(stdClass) }} | ||
--DATA-- | ||
return array('stdClass' => new \stdClass()) | ||
--EXCEPTION-- | ||
Twig_Error_Runtime: The "replace" filter expects an array or "Traversable" as replace values, got "stdClass" in "index.twig" at line 2. |
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