This PR was merged into the 1.x branch.
Discussion
----------
added support for PHP 7 null coalescing operator
fixes#1979
Commits
-------
6effc9a changed context access to use the PHP 7 null coalescing operator when available
This PR was merged into the 1.x branch.
Discussion
----------
renamed blockExists to hasBlock
As `hasBlock()` is marked as internal and because it's not even used anywhere in Twig, I've replaced its implementation with the one of `blockExists()`, and I also kept BC with a deprecation notice just in case someone is using it.
Commits
-------
59770a3 renamed blockExists to hasBlock
This PR was merged into the 1.x branch.
Discussion
----------
Add a "with" tag
Closes#719, alternative implementation of #1054
Commits
-------
4366907 added with tag
This PR was merged into the 1.x branch.
Discussion
----------
added support for a custom template on the block() function
`block()` allows one to render a block of the current template.
This PR adds the possibility to use `block()` to render a block of another template:
```twig
{{ block('footer', template_name) }}
```
As it uses the same logic as for the regular `block()`, you can also use it in a test:
```twig
{% if block('footer', template_name) is defined %}
...
{% endif %}
```
This removes the needs to use the internal `Twig_Template::renderBlock()` method in the Symfony Web Profiler for instance. And combined with #2236, it allows us to really mark the whole `Twig_Template` class as being internal.
I'm aware that #1302 asked for being able to pass a context to `block()` (implemented in #1433), but I prefer not to in favor of adding the `with` tag (see #719 and #1054).
When the `with` will be implemented, the code in the Symfony Web Profiler will become something along the lines of:
```twig
{% with {
'collector': profile.getcollector(name),
'profiler_url': profiler_url,
'token': profile.token,
'name': name
} %}
{{ block('toolbar', template) }}
{% endwith %}
```
Commits
-------
5ed59be added support for a custom template on the block() function
This PR was merged into the 1.x branch.
Discussion
----------
added 'is defined' support for constant
Commits
-------
c81bae4 added 'is defined' support for constant
This PR was merged into the 1.x branch.
Discussion
----------
Add "is defined" support for block()
replaces #1831, fixes#1821
I think reusing the semantic of the `defined` test is more idiomatic and easily discoverable.
/cc @hason
Commits
-------
3ce06af added 'is defined' support for block()
4f013e0 Add test to check if a block exists
This PR was merged into the 1.x branch.
Discussion
----------
removed old code that is not needed anymore
Commits
-------
60bed59 removed old code that is not needed anymore
This PR was merged into the 1.x branch.
Discussion
----------
added a proper error message when block() is called without arguments
Commits
-------
a63ee7c added a proper error message when block() is called without arguments
This PR was merged into the 2.x branch.
Discussion
----------
Bump minimum version to PHP 5.6
Twig 2.0 will be released really soon now (hopefully by the end of the year). So, it's time again to reconsider the minimum PHP version we want to support.
I would like to bump it to PHP 5.6 for the following reasons:
* PHP 5.5 is not supported anymore (not even security fixes now);
* the latest Ubuntu LTS is already using PHP 7!
* #2228 allows to improve performance significantly and having this without the `if`statement makes the optimization more interesting.
What do you think?
Commits
-------
af3b0a5 bumped minimum version to PHP 5.6
* 1.x:
updated CHANGELOG
bumped version to 1.28
added testing PHP 7.1
Enhance perf of Template::getAttribute()
added a note about the default escaping strategy
removed Xdebug on Travis
This PR was merged into the 1.x branch.
Discussion
----------
Enhance perf of Template::getAttribute()
Note that this is unproved statement for now :)
If someone has a benchmark and want to try, please do (and share results).
Commits
-------
bdbfb15 Enhance perf of Template::getAttribute()
This PR was merged into the 1.x branch.
Discussion
----------
added a note about the default escaping strategy
fixes#2061
Commits
-------
56556d7 added a note about the default escaping strategy
This PR was squashed before being merged into the 1.x branch (closes#2216).
Discussion
----------
Load templates from cache, even if they have just been compiled
Previously, when the cache was empty, the compiled template would be written to it, but `eval()`d from `$content`. In that case, it is not possible to step through (read: debug) the compiled template because at least xDebug does not have a clue where the code comes from.
With this change, PHP/xDebug can tell even on the first run (with an empty cache) where the code was loaded from.
Commits
-------
ff0abbb Load templates from cache, even if they have just been compiled
This PR was merged into the 1.x branch.
Discussion
----------
Allow construction without constructor arguments
Since we can dynamically add templates and its possible to not need to construct the loader without any initial templates. I've added the default argument to the constructor for simpler instantiation IE new Twig_Loader_Array();. This helps us on a project where we've extended the loader, and have no initial templates but need to add constructor parameters for no real reason.
Commits
-------
289f63c Allow construction without constructor arguments