mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 10:26:32 +00:00
Merge branch '2.x' into 3.x
* 2.x: [Doc] Minor fixes and removed belittling words fixed CHANGELOG bumped version to 2.11.4-DEV prepared the 2.11.3 release bumped version to 1.42.3-DEV prepared the 1.42.2 release
This commit is contained in:
@@ -17,8 +17,13 @@
|
||||
* bumped minimum PHP version to 7.2
|
||||
* removed PSR-0 classes
|
||||
|
||||
* 2.11.3 (2019-XX-XX)
|
||||
* 2.11.4 (2019-XX-XX)
|
||||
|
||||
* n/a
|
||||
|
||||
* 2.11.3 (2019-06-18)
|
||||
|
||||
* display partial output (PHP buffer) when an error occurs in debug mode
|
||||
* fixed the filter filter (allow the result to be used several times)
|
||||
* fixed macro auto-import when a template contains only macros
|
||||
|
||||
@@ -273,7 +278,11 @@
|
||||
* improved the performance of the filesystem loader
|
||||
* removed features that were deprecated in 1.x
|
||||
|
||||
* 1.42.2 (2019-XX-XX)
|
||||
* 1.42.3 (2019-XX-XX)
|
||||
|
||||
* n/a
|
||||
|
||||
* 1.42.2 (2019-06-18)
|
||||
|
||||
* Display partial output (PHP buffer) when an error occurs in debug mode
|
||||
|
||||
|
||||
+4
-4
@@ -798,10 +798,10 @@ This is very convenient but not recommended as it makes template compilation
|
||||
depend on runtime dependencies even if they are not needed (think for instance
|
||||
as a dependency that connects to a database engine).
|
||||
|
||||
You can easily decouple the extension definitions from their runtime
|
||||
implementations by registering a ``\Twig\RuntimeLoader\RuntimeLoaderInterface`` instance on
|
||||
the environment that knows how to instantiate such runtime classes (runtime
|
||||
classes must be autoload-able)::
|
||||
You can decouple the extension definitions from their runtime implementations by
|
||||
registering a ``\Twig\RuntimeLoader\RuntimeLoaderInterface`` instance on the
|
||||
environment that knows how to instantiate such runtime classes (runtime classes
|
||||
must be autoload-able)::
|
||||
|
||||
class RuntimeLoader implements \Twig\RuntimeLoader\RuntimeLoaderInterface
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ date, use a ternary operator:
|
||||
{{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }}
|
||||
|
||||
If no format is provided, Twig will use the default one: ``F j, Y H:i``. This
|
||||
default can be easily changed by calling the ``setDateFormat()`` method on the
|
||||
default can be changed by calling the ``setDateFormat()`` method on the
|
||||
``core`` extension instance. The first argument is the default format for
|
||||
dates and the second one is the default format for date intervals:
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ The ``date_modify`` filter modifies a date with a given modifier string:
|
||||
{{ post.published_at|date_modify("+1 day")|date("m/d/Y") }}
|
||||
|
||||
The ``date_modify`` filter accepts strings (it must be in a format supported
|
||||
by the `strtotime`_ function) or `DateTime`_ instances. You can easily combine
|
||||
by the `strtotime`_ function) or `DateTime`_ instances. You can combine
|
||||
it with the :doc:`date<date>` filter for formatting.
|
||||
|
||||
Arguments
|
||||
|
||||
@@ -30,7 +30,7 @@ options of:
|
||||
* ``.`` as the decimal point.
|
||||
* ``,`` as the thousands separator.
|
||||
|
||||
These defaults can be easily changed through the core extension:
|
||||
These defaults can be changed through the core extension:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
Twig Internals
|
||||
==============
|
||||
|
||||
Twig is very extensible and you can easily hack it. Keep in mind that you
|
||||
Twig is very extensible and you can hack it. Keep in mind that you
|
||||
should probably try to create an extension before hacking the core, as most
|
||||
features and enhancements can be handled with extensions. This chapter is also
|
||||
useful for people who want to understand how Twig works under the hood.
|
||||
|
||||
+5
-5
@@ -128,7 +128,7 @@ might be tempted to write the following:
|
||||
{# page.twig in .../templates/mysite #}
|
||||
{% extends "page.twig" %} {# from .../templates/default #}
|
||||
|
||||
Of course, this will not work as Twig will always load the template from
|
||||
However, this will not work as Twig will always load the template from
|
||||
``.../templates/mysite``.
|
||||
|
||||
It turns out it is possible to get this to work, by adding a directory right
|
||||
@@ -350,7 +350,7 @@ When attaching a visitor to a ``\Twig\Environment`` instance, Twig uses it to
|
||||
visit *all* templates it compiles. If you need to keep some state information
|
||||
around, you probably want to reset it when visiting a new template.
|
||||
|
||||
This can be easily achieved with the following code::
|
||||
This can be achieved with the following code::
|
||||
|
||||
protected $someTemplateState = [];
|
||||
|
||||
@@ -474,9 +474,9 @@ remove it from the database, and everything else will still work as before.
|
||||
Loading a Template from a String
|
||||
--------------------------------
|
||||
|
||||
From a template, you can easily load a template stored in a string via the
|
||||
``template_from_string`` function (via the ``\Twig\Extension\StringLoaderExtension``
|
||||
extension):
|
||||
From a template, you can load a template stored in a string via the
|
||||
``template_from_string`` function (via the
|
||||
``\Twig\Extension\StringLoaderExtension`` extension):
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ Named Block End-Tags
|
||||
--------------------
|
||||
|
||||
Twig allows you to put the name of the block after the end tag for better
|
||||
readability:
|
||||
readability (the name after the ``endblock`` word must match the block name):
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
@@ -114,8 +114,6 @@ readability:
|
||||
{% endblock inner_sidebar %}
|
||||
{% endblock sidebar %}
|
||||
|
||||
Of course, the name after the ``endblock`` word must match the block name.
|
||||
|
||||
Block Nesting and Scope
|
||||
-----------------------
|
||||
|
||||
|
||||
+1
-3
@@ -134,12 +134,10 @@ Named Macro End-Tags
|
||||
--------------------
|
||||
|
||||
Twig allows you to put the name of the macro after the end tag for better
|
||||
readability:
|
||||
readability (the name after the ``endmacro`` word must match the macro name):
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{% macro input() %}
|
||||
...
|
||||
{% endmacro input %}
|
||||
|
||||
Of course, the name after the ``endmacro`` word must match the macro name.
|
||||
|
||||
Reference in New Issue
Block a user