This PR was merged into the 1.16-dev branch.
Discussion
----------
Use LimitIterator on Iterable objects within the slice filter
Previously the `slice` filter would create an array of items if the subject to be sliced implemented Traversable, this PR instead passes the subject to LimitIterator first - but only if `$start` and `$length` are positive values as LimitIterator does not support the "n'th from end" behaviour.
Our use case is that we have an API client, which we pass to slice, that implements Traversable but lazy loads the items to be returned via an API when `Iterator::current()` is called. Here a quick example:-
```
{% for item in client.items | slice(0,5) %}
{{ item.name }}
{% endfor %}
<img src="/assets/useless-sodding-banner.jpg" />
{% for item in client.items | slice(5,10) %}
{{ item.name }}
{% endfor %}
```
Current behaviour would mean that the client would issue 15 requests to the API, 5 for the first block, and 10 for the second (but only return items 5 to 10). This PR means only 10 requests are made, 5 in each block.
I'd imagine this would lower memory usage too.
Commits
-------
fdddb1c Use LimitIterator on Iterable objects within the splice filter
This PR was merged into the 1.16-dev branch.
Discussion
----------
Update convert_encoding.rst: wrong argument order
The arguments are in incorrect order. The first should be `to` and the second should be `from` - just like the text describes it.
Commits
-------
4e1d9a7 Update convert_encoding.rst
This PR was squashed before being merged into the 1.16-dev branch (closes#1500).
Discussion
----------
fix inconsistent response from twig_slice
twig_slice can return a boolean when slicing a string outside of its bounds and mbstring is not available. this would cause a knock-on error in twig_first/twig_last when calling current()
this (as suggested) adds a cast to emulate the behaviour of mb_substr for substr.
Commits
-------
c740060 fix inconsistent response from twig_slice
This PR was merged into the 1.16-dev branch.
Discussion
----------
date() documentation correction
The date() docs were incorrectly stating that the argument should be in a format supported by PHP’s [date()](http://php.net/manual/en/function.date.php) function. That’s true of the |date filter which is used to _format_ dates, but not the date() function, which is used to _create_ new dates.
I double-checked the code and whatever you pass into date() ultimately will get passed to a [DateTime constructor](http://php.net/manual/en/datetime.construct.php), which accepts an actual date string, formatted in one of PHP’s [date and time format](http://php.net/manual/en/datetime.formats.php), which is a different beast than the actual format definition string you might pass into PHP’s date() function.
Commits
-------
2f5a927 date() documentation correction
This PR was merged into the 1.16-dev branch.
Discussion
----------
Update installation.rst
Refer to PGP signature verification in the installation instructions for tarballs.
Commits
-------
3c48cb1 Update installation.rst
This PR was merged into the 1.16-dev branch.
Discussion
----------
Added note about array_merge php function
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
Just a small doc improvement.
Commits
-------
f712b8f Added note about array_merge php function
This PR was merged into the 1.16-dev branch.
Discussion
----------
Delimit comment in template using correct syntax
Enclose the comment in '{# #}' instead of beginning line with '#'.
Commits
-------
4e1515c Delimit comment in template using correct syntax
This PR was merged into the 1.16-dev branch.
Discussion
----------
Improved exception message while trying to access an attribute from an empty array
Rebased #1439 in master and updated twig extension
Commits
-------
759a77d [Ext] updating Twig extension for previous commit
15ce450 Improved exception message while trying to access an attribute from an empty array.
This PR was merged into the 1.16-dev branch.
Discussion
----------
Fixed "starts with" a "ends with" operators for non-string arguments
Commits
-------
4c26981 Fixed "starts with" a "ends with" operators for non-string arguments
This PR was merged into the 1.16-dev branch.
Discussion
----------
Fixed 'starts with' operator for empty needle
Fixes#1432
Commits
-------
790305a Fixed 'starts with' operator for empty needle
This PR was merged into the 1.16-dev branch.
Discussion
----------
Some minor cleanup
Commits
-------
e6da6bb Restore unused var
d8e1077 Get rid of naming clash
3e50672 Remove unused local vars
291141f Remove unused var
9921554 Fix type hint
1d2b877 Fix type hint
This PR was merged into the 1.16-dev branch.
Discussion
----------
Add variables types in error message of twig_array_merge
Commits
-------
ea6676d add variables types in error message of twig_array_merge
This PR was merged into the 1.16-dev branch.
Discussion
----------
Fixed the `matches` operator code example
A customer just pointed out that your `matches` operator code example wasn't working for them, and it ended up being because its backslashes themselves needed to be escaped by additional backslashes. (I've verified this.)
While I was editing it, I also switched to forwardslash delimiters on the regex, since those are much more commonly used than curly brackets. (I hadn't even been aware that curly brackets are allowed.) To back that assertion up, [PHP's official preg_quote() docs](http://php.net/manual/en/function.preg-quote.php) state:
> The `/` is the most commonly used delimiter.
Commits
-------
33dcbc8 Fixed the `matches` operator code example
It wasn't working because the backslashes themselves needed to be escaped by additional backslashes. Also switched to using forwardslashes for the regex delimiters rather than curly brackets.
This PR was squashed before being merged into the 1.16-dev branch (closes#1453).
Discussion
----------
Fix for mb function overload mb_substr acting different
When bug hunting https://github.com/fabpot/Twig/issues/1428 I ran into an issue.
I started out by changing my `php.ini` for the `cli` enviroment, I've added:
`mbstring.func_overload = 2`
Later I tested with adding and removing:
`mbstring.internal_encoding = 'UTF-8'`
It turns out `mb_substr` returns `false` and not `''` when doing something like this:
```php
$item = '';
$start = -1;
$length = 1;
$charset = 'UTF-8';
$a = mb_substr($item, $start, $length, $charset);
var_dump($a);
die;
```
I'm not sure this will fix 1428 since I don't have enough information for this, but this PR should at least fix one issue.
Commits
-------
214fe52 Fix for mb function overload mb_substr acting different
This PR was merged into the 1.16-dev branch.
Discussion
----------
Added disambiguation on using raw in expressions
I recently got in trouble using the ``raw`` filter in a ternary, leading to a value being escaped and me not expecting it. The code was :
```
{{ foo|striptags|length > 250 ? foo|striptags|slice(0, 250) ~ '...' : foo|raw }}
```
When foo's length was under 250 characters, the result of this expression was escaped. Here is the updated documentation to explain why.
Commits
-------
cec2b57 Added disambiguation on using raw in expressions