Commit Graph

3304 Commits

Author SHA1 Message Date
Fabien Potencier c500bedbd9 Merge branch '1.x' into 2.x
* 1.x:
  changed context access to use the PHP 7 null coalescing operator when available
  renamed blockExists to hasBlock
2016-11-12 19:42:58 -08:00
Fabien Potencier 827d8e7795 minor #2238 added support for PHP 7 null coalescing operator (fabpot)
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
2016-11-12 19:33:53 -08:00
Fabien Potencier 6effc9aa34 changed context access to use the PHP 7 null coalescing operator when available 2016-11-12 19:30:09 -08:00
Fabien Potencier dc43edaa87 removed obsolete code 2016-11-12 18:55:08 -08:00
Fabien Potencier 4419ff3ae4 minor #2248 renamed blockExists to hasBlock (fabpot)
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
2016-11-12 18:47:19 -08:00
Fabien Potencier 59770a33f7 renamed blockExists to hasBlock 2016-11-12 18:29:20 -08:00
Fabien Potencier 4c39e930cd remove obsolete docs 2016-11-12 18:12:38 -08:00
Fabien Potencier 26fefedbae Merge branch '1.x' into 2.x
* 1.x:
  updated CHANGELOG
  added with tag
  added missing docs
  added support for a custom template on the block() function
2016-11-12 18:11:17 -08:00
Fabien Potencier a50f765ad9 updated CHANGELOG 2016-11-12 17:42:35 -08:00
Fabien Potencier aa2ca14e88 feature #2246 Add a "with" tag (fabpot)
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
2016-11-12 17:41:49 -08:00
Fabien Potencier 4366907d73 added with tag 2016-11-12 17:40:47 -08:00
Fabien Potencier 02b084e2f5 feature #2245 added support for a custom template on the block() function (fabpot)
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
2016-11-12 17:38:59 -08:00
Fabien Potencier bbd30b03a5 minor #2247 Missing docs (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Missing docs

Commits
-------

065b2e2 added missing docs
2016-11-12 17:37:58 -08:00
Fabien Potencier 065b2e26a2 added missing docs 2016-11-12 17:36:55 -08:00
Fabien Potencier 5ed59be9c5 added support for a custom template on the block() function 2016-11-12 17:34:29 -08:00
Fabien Potencier 05e1c68c4b Merge branch '1.x' into 2.x
* 1.x:
  added some more tests
  added 'is defined' support for constant
  added 'is defined' support for block()
  Add test to check if a block exists
2016-11-11 13:50:46 -08:00
Fabien Potencier c19448545a minor #2241 added some more tests (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

added some more tests

Commits
-------

b23cc3b added some more tests
2016-11-11 13:49:36 -08:00
Fabien Potencier 1c2bec9112 feature #2242 added 'is defined' support for constant (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

added 'is defined' support for constant

Commits
-------

c81bae4 added 'is defined' support for constant
2016-11-11 13:49:19 -08:00
Fabien Potencier b23cc3b4a1 added some more tests 2016-11-11 13:45:13 -08:00
Fabien Potencier c81bae489e added 'is defined' support for constant 2016-11-11 13:40:51 -08:00
Fabien Potencier 0d6581bf64 feature #2239 Add "is defined" support for block() (hason, fabpot)
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
2016-11-11 12:08:12 -08:00
Fabien Potencier 3ce06af6b4 added 'is defined' support for block() 2016-11-11 12:03:32 -08:00
Martin Hasoň 4f013e09ea Add test to check if a block exists 2016-11-11 12:02:25 -08:00
Fabien Potencier 80fa648663 Merge branch '1.x' into 2.x
* 1.x:
  removed old code that is not needed anymore
2016-11-11 12:00:59 -08:00
Fabien Potencier c577631f39 minor #2240 removed old code that is not needed anymore (fabpot)
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
2016-11-11 11:59:57 -08:00
Fabien Potencier 60bed59266 removed old code that is not needed anymore 2016-11-11 11:38:25 -08:00
Fabien Potencier 52cd58cbab Merge branch '1.x' into 2.x
* 1.x:
  added a proper error message when block() is called without arguments
  removed some unneeded phpdocs
2016-11-11 08:44:36 -08:00
Fabien Potencier 9cede85c5f minor #2234 removed some unneeded phpdocs (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

removed some unneeded phpdocs

Commits
-------

f21c44c removed some unneeded phpdocs
2016-11-11 08:37:49 -08:00
Fabien Potencier fc53b5ab18 bug #2237 added a proper error message when block() is called without arguments (fabpot)
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
2016-11-11 07:07:12 -08:00
Fabien Potencier a63ee7c6fb added a proper error message when block() is called without arguments 2016-11-10 21:27:25 -08:00
Fabien Potencier abaa2c19de minor #2235 Simplify code (fabpot)
This PR was merged into the 2.x branch.

Discussion
----------

Simplify code

Commits
-------

d964b55 simplified code
2016-11-10 13:41:00 -08:00
Fabien Potencier d964b551b2 simplified code 2016-11-10 13:30:55 -08:00
Fabien Potencier f21c44cd67 removed some unneeded phpdocs 2016-11-10 13:24:47 -08:00
Fabien Potencier b8f1dc59c1 feature #2229 Bump minimum version to PHP 5.6 (fabpot)
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
2016-11-10 11:50:59 -08:00
Fabien Potencier af3b0a550c bumped minimum version to PHP 5.6 2016-11-10 11:37:20 -08:00
Fabien Potencier fa4a5ebf31 Merge branch '1.x' into 2.x
* 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
2016-11-10 11:33:40 -08:00
Fabien Potencier 924c2f4813 updated CHANGELOG 2016-11-10 11:30:21 -08:00
Fabien Potencier 81a174ff6c feature #2228 Enhance perf of Template::getAttribute() (nicolas-grekas)
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()
2016-11-10 11:29:27 -08:00
Fabien Potencier d630f870a7 bumped version to 1.28 2016-11-10 11:28:46 -08:00
Fabien Potencier 61f840c85f minor #2231 Remove Xdebug for tests (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Remove Xdebug for tests

Commits
-------

498dcf4 removed Xdebug on Travis
2016-11-10 11:24:03 -08:00
Fabien Potencier 224deeb3e9 minor #2232 Add testing PHP 7.1 (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Add testing PHP 7.1

Commits
-------

56e09fb added testing PHP 7.1
2016-11-10 11:23:51 -08:00
Fabien Potencier 56e09fb7d3 added testing PHP 7.1 2016-11-10 11:15:19 -08:00
Nicolas Grekas bdbfb15111 Enhance perf of Template::getAttribute() 2016-11-10 19:43:25 +01:00
Fabien Potencier 1c99469bcc minor #2227 added a note about the default escaping strategy (fabpot)
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
2016-11-10 10:28:59 -08:00
Fabien Potencier 56556d72f8 added a note about the default escaping strategy 2016-11-10 10:28:06 -08:00
Fabien Potencier b82accd78f Merge branch '1.x' into 2.x
* 1.x:
  fixed typo
  Load templates from cache, even if they have just been compiled
  Allow construction without constructor arguments
2016-11-08 12:47:43 -08:00
Fabien Potencier dc3533c347 fixed typo 2016-11-08 12:40:21 -08:00
Fabien Potencier b37db3bc93 bug #2216 Load templates from cache, even if they have just been compiled (mpdude)
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
2016-11-07 19:10:29 -08:00
Matthias Pigulla ff0abbb7e8 Load templates from cache, even if they have just been compiled 2016-11-07 19:10:26 -08:00
Fabien Potencier 3314cd546e minor #2214 Allow construction without constructor arguments (gnat42)
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
2016-11-07 11:42:43 -08:00