Commit Graph

2328 Commits

Author SHA1 Message Date
Fabien Potencier 0d0cdba3bb udpated CHANGELOG 2014-10-01 19:13:04 +02:00
Fabien Potencier 1ed333bfb9 feature #1503 Use LimitIterator on Iterable objects within the slice filter (Anthony Sterling)
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
2014-10-01 19:09:15 +02:00
Fabien Potencier 0a179e801a fixed typo 2014-10-01 13:22:22 +02:00
Fabien Potencier 0b2f373fc4 deprecated Node::toXml() 2014-10-01 13:19:23 +02:00
Fabien Potencier fcdb9487cc minor #1509 Update convert_encoding.rst: wrong argument order (binarious)
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
2014-10-01 07:31:33 +02:00
Fabien Potencier 9c12486651 fixed some assertions 2014-09-30 19:44:16 +02:00
Fabien Potencier 53b7001342 bug #1500 fix inconsistent response from twig_slice (rodnaph)
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
2014-09-30 19:40:30 +02:00
Rhodri Pugh c740060051 fix inconsistent response from twig_slice 2014-09-30 19:40:27 +02:00
Fabien Potencier 82cd5475a3 minor #1520 date() documentation correction (brandonkelly)
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
2014-09-30 19:37:32 +02:00
Brandon Kelly 2f5a927b72 date() documentation correction 2014-09-30 10:07:37 -07:00
binarious 4e1d9a7522 Update convert_encoding.rst
The arguments were in incorrect order. The first should be `to` and the second should be `from` - just like the text describes it.
2014-09-22 11:29:45 +02:00
Anthony Sterling fdddb1c91e Use LimitIterator on Iterable objects within the splice filter 2014-09-10 15:32:22 +01:00
Fabien Potencier 084ca201a7 minor #1492 add PHP 5.6 to .travis.yml (sasezaki)
This PR was merged into the 1.16-dev branch.

Discussion
----------

add PHP 5.6 to .travis.yml

Commits
-------

ed7004b add PHP 5.6 to .travis.yml
2014-09-02 16:08:17 +02:00
kazusuke sasezaki ed7004b524 add PHP 5.6 to .travis.yml 2014-08-29 00:51:54 +09:00
Fabien Potencier 9cd07271c3 minor #1474 Update installation.rst (soatok)
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
2014-08-27 11:26:36 +02:00
Fabien Potencier a4867487f2 minor #1487 Added note about array_merge php function (pulzarraider)
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
2014-08-27 11:25:58 +02:00
Fabien Potencier 07b8651ce9 minor #1484 Delimit comment in template using correct syntax (johnberberich)
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
2014-08-27 11:24:21 +02:00
Andrej Hudec f712b8f8e6 Added note about array_merge php function 2014-08-24 00:31:40 +02:00
John Berberich 4e1515c3c5 Delimit comment in template using correct syntax
Enclose the comment in '{# #}' instead of beginning line with '#'.
2014-08-22 10:11:09 -04:00
Fabien Potencier e2d2a250d9 minor #1475 Improved exception message while trying to access an attribute from an empty array (phansys, tucksaun)
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.
2014-08-06 08:46:32 +02:00
Tugdual Saunier 759a77d040 [Ext] updating Twig extension for previous commit 2014-08-06 07:18:48 +01:00
Javier Spagnoletti 15ce450e32 Improved exception message while trying to access an attribute from an empty array. 2014-08-06 07:18:32 +01:00
Fabien Potencier da2d52b022 updated CHANGELOG 2014-08-05 14:54:54 +02:00
Soatok 3c48cb1140 Update installation.rst
Refer to PGP signature verification in the installation instructions for tarballs.
2014-08-05 08:33:51 -04:00
Fabien Potencier 3e6c9551eb changed the way we check for HHVM 2014-08-04 21:55:24 +02:00
Fabien Potencier 1d093a4137 minor #1471 Fixed a test on hhvm (hason)
This PR was merged into the 1.16-dev branch.

Discussion
----------

Fixed a test on hhvm

Commits
-------

0c169ce Fixed a test on hhvm
2014-08-04 21:54:18 +02:00
Martin Hasoň 0c169ce98c Fixed a test on hhvm 2014-08-04 12:46:42 +02:00
Fabien Potencier 54da75aebf bug #1468 Fixed "starts with" a "ends with" operators for non-string arguments (hason)
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
2014-08-03 10:10:53 +02:00
Martin Hasoň 4c26981ce5 Fixed "starts with" a "ends with" operators for non-string arguments 2014-08-02 17:11:21 +02:00
Fabien Potencier 0c508d2703 bug #1452 Fixed 'starts with' operator for empty needle (hason)
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
2014-08-01 17:28:52 +02:00
Martin Hasoň 790305af93 Fixed 'starts with' operator for empty needle 2014-08-01 14:43:36 +02:00
Fabien Potencier 21f0b829f9 added more docs for the if tag 2014-08-01 09:38:44 +02:00
Fabien Potencier c03a7a323a fixed the attribute() function when passing a variable for the arguments 2014-08-01 09:18:16 +02:00
Fabien Potencier 72aa82b9a2 minor #1465 Some minor cleanup (JeroenDeDauw)
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
2014-07-31 15:21:40 +02:00
Fabien Potencier 3ad428fe1d minor #1462 Simplified Twig_Node_Include (hason)
This PR was merged into the 1.16-dev branch.

Discussion
----------

Simplified Twig_Node_Include

Commits
-------

632fe90 Simplified Twig_Node_Include
2014-07-31 15:20:45 +02:00
Fabien Potencier 30d4f2b2b1 minor #1458 Add variables types in error message of twig_array_merge (inalgnu)
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
2014-07-31 13:15:54 +02:00
jeroendedauw e6da6bb0d4 Restore unused var 2014-07-31 12:30:50 +02:00
jeroendedauw d8e1077fd1 Get rid of naming clash
Static code analysis tool did not like this.
Looks like it was wrong before. Tests unchanged though.
2014-07-31 10:38:31 +02:00
jeroendedauw 3e50672029 Remove unused local vars 2014-07-31 10:37:48 +02:00
jeroendedauw 291141f869 Remove unused var 2014-07-31 10:37:40 +02:00
jeroendedauw 99215549a9 Fix type hint
In PHPStorm the inferred type was 'A'
2014-07-31 10:37:12 +02:00
jeroendedauw 1d2b8777d0 Fix type hint
PHPStorm wrongly inferred the type 'Unicode'
2014-07-31 10:36:30 +02:00
Martin Hasoň 632fe90000 Simplified Twig_Node_Include 2014-07-31 09:18:56 +02:00
Inal DJAFAR ea6676d61a add variables types in error message of twig_array_merge 2014-07-30 17:44:54 +02:00
Fabien Potencier 4134169b67 minor #1457 Fixed the matches operator code example (brandonkelly)
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
2014-07-29 13:54:16 +02:00
Brandon Kelly 33dcbc8c76 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.
2014-07-28 11:37:46 -07:00
Fabien Potencier 7d1577ff3c bug #1453 Fix for mb function overload mb_substr acting different (1emming)
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
2014-07-28 15:12:00 +02:00
1emming 214fe52174 Fix for mb function overload mb_substr acting different 2014-07-28 15:11:49 +02:00
Fabien Potencier 5fd428ed76 fixed some typos 2014-07-08 15:46:25 +02:00
Fabien Potencier 82a034c591 minor #1333 Added disambiguation on using raw in expressions (OwlyCode)
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
2014-07-08 15:44:12 +02:00