This PR was squashed before being merged into the 1.x branch (closes#2420).
Discussion
----------
Make "length" filter and "empty" test consider __toString [Twig 1.x]
Use case: When you have variables in your views that are actually objects but implement `__toString`, they feel like strings: For example, `{{ something }}` will make use of that to-string-conversion.
What does *not* work is
**a)** `{{ something | length }}`, because that will only have a meaningful return value for objects implementing `\Countable`. This interface, however, may have a totally different semantic/purpose for the object in question.
**b)** `{% if something is empty %}`, because
> empty checks if a variable is an empty string, an empty array, an empty hash, exactly false, or exactly null `[http://twig.sensiolabs.org/doc/2.x/tests/empty.html]`
... and obviously `something !== null` in this case.
For template designers, this may be surprising if they don't actually care about the object-or-string difference, they just "use" the variable.
This change tries to address this as it changes the behavior for such objects that have a `__toString` method and are *not* `\Countable`.
*Yes*, it's a BC break in edge cases:
For a), objects that implement a `__toString` but not `\Countable` would previously yield `1` for `{{ object | length }}`, and now would return the length of the string returned by `__toString`.
For b), testing (defined) variables that are objects implementing `__toString` and that return `''`, the test now is `false`.
Commits
-------
f5193e92 Make "length" filter and "empty" test consider __toString [Twig 1.x]
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2427).
Discussion
----------
Fixed JS escaping for unicode characters with higher code points
Unicode characters with higher code points were being escaped incorrectly. When these characters are escaped, they should maintain their surrogate halves. Previously, Twig was dropping the first surrogate half.
https://mathiasbynens.be/notes/javascript-escapes#unicode-code-point
> The tetragram for centre symbol (𝌆) has code point U+1D306, so you could write it as \u{1D306}. For comparison, if you were to use simple Unicode escapes to represent this symbol, you’d have to write out the surrogate halves separately: '\uD834\uDF06'.
Commits
-------
7f913495 Fixed JS escaping for unicode characters with higher code points
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2422).
Discussion
----------
Updated the vim-twig link
The other project is not maintained anymore and the author recommends this fork.
Commits
-------
955d5abd Updated the vim-twig link
This PR was merged into the 1.x branch.
Discussion
----------
PHPUnit 6 compatability
This should make builds on Traivs CI green again.
Commits
-------
0d791de6 PHPUnit 6 compatability
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2421).
Discussion
----------
Fix codeblock in recipes documentation
Commits
-------
adba4c2a Fix codeblock
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2403).
Discussion
----------
#1802 left/right trim
It was said in this thread that there was a preference of adding parameters to the trim filter in order to implement this.
So this feature works like:
trim(character_mask, mode), where mode is either "both", "left" or "right". It is by default "both".
This is my first pull request of this project, so I apologise in advance if something is wrong.
Commits
-------
7d8e7550#1802 left/right trim
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2406).
Discussion
----------
Fix tokenize call in DeprecationCollector
Hi,
if fixes `Argument 1 passed to Twig_Environment::tokenize() must be an instance of Twig_Source, string given`
Commits
-------
13ca97c1 Fix tokenize call in DeprecationCollector
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2371).
Discussion
----------
Update striptags.rst
Add information about supported param. Replaces #2370
Commits
-------
048f5490 Update striptags.rst
This PR was squashed before being merged into the 1.x branch (closes#2388).
Discussion
----------
Mention autoescape=true deprecation (issue #2386)
Per #2386, mention the deprecation of true in favor of an explicit "html".
Commits
-------
70d03042 Mention autoescape=true deprecation (issue #2386)
This PR was merged into the 1.x branch.
Discussion
----------
Turned fatal error into exception when a previously generated cache prevents loading its newly compiled version
Not sure if this is testable, yet this should save some hours to people that end up in the same trap we did on our project.
It turned out we generated some twig template cache in two separate commands, in a situation where "index" tracking for embeds where lost.
This PR detects the situation and invites to clear the cache properly, because that's the only way to fix the issue.
It also fixes a mistake in the cache $key generation, that should not take $index into account.
Doing so were making offline cache warmup useless in some situations.
Commits
-------
95c10991 Turned fatal error into exception when a previously generated cache prevents loading its newly compiled version