Fix typos in CHANGELOG

This commit is contained in:
Fabien Potencier
2024-08-17 17:59:11 +02:00
parent 1d5a8dc98b
commit 84116e5ff7
11 changed files with 41 additions and 23 deletions
+1
View File
@@ -1,5 +1,6 @@
# 3.12.0 (2024-XX-XX) # 3.12.0 (2024-XX-XX)
* Accept colons (`:`) in addition to equals (`=`) to separate argument names and values in named arguments
* Add the `html_cva` function (in the HTML extra package) * Add the `html_cva` function (in the HTML extra package)
* Add support for named arguments to the `block` and `attribute` functions * Add support for named arguments to the `block` and `attribute` functions
* Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments * Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments
+6
View File
@@ -105,3 +105,9 @@ standards:
true true
{% endif %} {% endif %}
{% endblock %} {% endblock %}
* Use ``:`` instead of ``=`` to separate argument names and values:
.. code-block:: twig
{{ data|convert_encoding(from: 'iso-2022-jp', to: 'UTF-8') }}
+3 -3
View File
@@ -11,13 +11,13 @@ The ``data_uri`` filter generates a URL using the data scheme as defined in
{{ source('path_to_image')|data_uri }} {{ source('path_to_image')|data_uri }}
{# force the mime type, disable the guessing of the mime type #} {# force the mime type, disable the guessing of the mime type #}
{{ image_data|data_uri(mime="image/svg") }} {{ image_data|data_uri(mime: "image/svg") }}
{# also works with plain text #} {# also works with plain text #}
{{ '<b>foobar</b>'|data_uri(mime="text/html") }} {{ '<b>foobar</b>'|data_uri(mime: "text/html") }}
{# add some extra parameters #} {# add some extra parameters #}
{{ '<b>foobar</b>'|data_uri(mime="text/html", parameters={charset: "ascii"}) }} {{ '<b>foobar</b>'|data_uri(mime: "text/html", parameters: {charset: "ascii"}) }}
.. note:: .. note::
+1 -1
View File
@@ -45,7 +45,7 @@ By default, the filter uses the current locale. You can pass it explicitly:
.. code-block:: twig .. code-block:: twig
{# 1.000.000,00 € #} {# 1.000.000,00 € #}
{{ '1000000'|format_currency('EUR', locale='de') }} {{ '1000000'|format_currency('EUR', locale: 'de') }}
.. note:: .. note::
+7 -7
View File
@@ -16,13 +16,13 @@ You can tweak the output for the date part and the time part:
.. code-block:: twig .. code-block:: twig
{# 23:39 #} {# 23:39 #}
{{ '2019-08-07 23:39:12'|format_datetime('none', 'short', locale='fr') }} {{ '2019-08-07 23:39:12'|format_datetime('none', 'short', locale: 'fr') }}
{# 07/08/2019 #} {# 07/08/2019 #}
{{ '2019-08-07 23:39:12'|format_datetime('short', 'none', locale='fr') }} {{ '2019-08-07 23:39:12'|format_datetime('short', 'none', locale: 'fr') }}
{# mercredi 7 août 2019 23:39:12 UTC #} {# mercredi 7 août 2019 23:39:12 UTC #}
{{ '2019-08-07 23:39:12'|format_datetime('full', 'full', locale='fr') }} {{ '2019-08-07 23:39:12'|format_datetime('full', 'full', locale: 'fr') }}
Supported values are: ``none``, ``short``, ``medium``, ``long``, and ``full``. Supported values are: ``none``, ``short``, ``medium``, ``long``, and ``full``.
@@ -38,7 +38,7 @@ For greater flexibility, you can even define your own pattern
.. code-block:: twig .. code-block:: twig
{# 11 oclock PM, GMT #} {# 11 oclock PM, GMT #}
{{ '2019-08-07 23:39:12'|format_datetime(pattern="hh 'oclock' a, zzzz") }} {{ '2019-08-07 23:39:12'|format_datetime(pattern: "hh 'oclock' a, zzzz") }}
Locale Locale
------ ------
@@ -48,7 +48,7 @@ By default, the filter uses the current locale. You can pass it explicitly:
.. code-block:: twig .. code-block:: twig
{# 7 août 2019 23:39:12 #} {# 7 août 2019 23:39:12 #}
{{ '2019-08-07 23:39:12'|format_datetime(locale='fr') }} {{ '2019-08-07 23:39:12'|format_datetime(locale: 'fr') }}
Timezone Timezone
-------- --------
@@ -59,14 +59,14 @@ it by explicitly specifying a timezone:
.. code-block:: twig .. code-block:: twig
{{ datetime|format_datetime(locale='en', timezone='Pacific/Midway') }} {{ datetime|format_datetime(locale: 'en', timezone: 'Pacific/Midway') }}
If the date is already a DateTime object, and if you want to keep its current If the date is already a DateTime object, and if you want to keep its current
timezone, pass ``false`` as the timezone value: timezone, pass ``false`` as the timezone value:
.. code-block:: twig .. code-block:: twig
{{ datetime|format_datetime(locale='en', timezone=false) }} {{ datetime|format_datetime(locale: 'en', timezone: false) }}
The default timezone can also be set globally by calling ``setTimezone()``:: The default timezone can also be set globally by calling ``setTimezone()``::
+3 -3
View File
@@ -44,10 +44,10 @@ Besides plain numbers, the filter can also format numbers in various styles:
.. code-block:: twig .. code-block:: twig
{# 1,234% #} {# 1,234% #}
{{ '12.345'|format_number(style='percent') }} {{ '12.345'|format_number(style: 'percent') }}
{# twelve point three four five #} {# twelve point three four five #}
{{ '12.345'|format_number(style='spellout') }} {{ '12.345'|format_number(style: 'spellout') }}
{# 12 sec. #} {# 12 sec. #}
{{ '12'|format_duration_number }} {{ '12'|format_duration_number }}
@@ -85,7 +85,7 @@ By default, the filter uses the current locale. You can pass it explicitly:
.. code-block:: twig .. code-block:: twig
{# 12,345 #} {# 12,345 #}
{{ '12.345'|format_number(locale='fr') }} {{ '12.345'|format_number(locale: 'fr') }}
.. note:: .. note::
+1 -1
View File
@@ -14,7 +14,7 @@ and end of a string:
{# outputs ' I like Twig' #} {# outputs ' I like Twig' #}
{{ ' I like Twig. '|trim(side='left') }} {{ ' I like Twig. '|trim(side: 'left') }}
{# outputs 'I like Twig. ' #} {# outputs 'I like Twig. ' #}
+12 -7
View File
@@ -210,11 +210,16 @@ built-in functions.
Named Arguments Named Arguments
--------------- ---------------
Named arguments are supported in functions, filters and tests. Named arguments are supported in functions, filters, and tests.
.. versionadded:: 3.12
Twig supports both ``=`` and ``:`` as separators between argument names and
values, but support for ``:`` was introduced in Twig 3.12.
.. code-block:: twig .. code-block:: twig
{% for i in range(low=1, high=10, step=2) %} {% for i in range(low: 1, high: 10, step: 2) %}
{{ i }}, {{ i }},
{% endfor %} {% endfor %}
@@ -227,7 +232,7 @@ the values you pass as arguments:
{# versus #} {# versus #}
{{ data|convert_encoding(from='iso-2022-jp', to='UTF-8') }} {{ data|convert_encoding(from: 'iso-2022-jp', to: 'UTF-8') }}
Named arguments also allow you to skip some arguments for which you don't want Named arguments also allow you to skip some arguments for which you don't want
to change the default value: to change the default value:
@@ -238,19 +243,19 @@ to change the default value:
{{ "now"|date(null, "Europe/Paris") }} {{ "now"|date(null, "Europe/Paris") }}
{# or skip the format value by using a named argument for the time zone #} {# or skip the format value by using a named argument for the time zone #}
{{ "now"|date(timezone="Europe/Paris") }} {{ "now"|date(timezone: "Europe/Paris") }}
You can also use both positional and named arguments in one call, in which You can also use both positional and named arguments in one call, in which
case positional arguments must always come before named arguments: case positional arguments must always come before named arguments:
.. code-block:: twig .. code-block:: twig
{{ "now"|date('d/m/Y H:i', timezone="Europe/Paris") }} {{ "now"|date('d/m/Y H:i', timezone: "Europe/Paris") }}
.. tip:: .. tip::
Each function and filter documentation page has a section where the names Each function, filter, and test documentation page has a section where the
of all arguments are listed when supported. names of all supported arguments are listed.
Control Structure Control Structure
----------------- -----------------
+1 -1
View File
@@ -639,7 +639,7 @@ class ExpressionParser
} }
$name = null; $name = null;
if ($namedArguments && $token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) { if ($namedArguments && (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || ($token = $stream->nextIf(Token::PUNCTUATION_TYPE, ':')))) {
if (!$value instanceof NameExpression) { if (!$value instanceof NameExpression) {
throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', \get_class($value)), $token->getLine(), $stream->getSourceContext()); throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', \get_class($value)), $token->getLine(), $stream->getSourceContext());
} }
+4
View File
@@ -3,10 +3,12 @@
--TEMPLATE-- --TEMPLATE--
{{ attribute(obj, method) }} {{ attribute(obj, method) }}
{{ attribute(variable=obj, attribute=method) }} {{ attribute(variable=obj, attribute=method) }}
{{ attribute(variable: obj, attribute: method) }}
{{ attribute(array, item) }} {{ attribute(array, item) }}
{{ attribute(obj, "bar", ["a", "b"]) }} {{ attribute(obj, "bar", ["a", "b"]) }}
{{ attribute(obj, "bar", arguments) }} {{ attribute(obj, "bar", arguments) }}
{{ attribute(variable=obj, attribute="bar", arguments=arguments) }} {{ attribute(variable=obj, attribute="bar", arguments=arguments) }}
{{ attribute(variable: obj, attribute: "bar", arguments: arguments) }}
{{ attribute(obj, method) is defined ? 'ok' : 'ko' }} {{ attribute(obj, method) is defined ? 'ok' : 'ko' }}
{{ attribute(obj, nonmethod) is defined ? 'ok' : 'ko' }} {{ attribute(obj, nonmethod) is defined ? 'ok' : 'ko' }}
--DATA-- --DATA--
@@ -14,9 +16,11 @@ return ['obj' => new Twig\Tests\TwigTestFoo(), 'method' => 'foo', 'array' => ['f
--EXPECT-- --EXPECT--
foo foo
foo foo
foo
bar bar
bar_a-b bar_a-b
bar_a-b bar_a-b
bar_a-b bar_a-b
bar_a-b
ok ok
ko ko
@@ -3,9 +3,11 @@
--TEMPLATE-- --TEMPLATE--
{{ date(date, "America/New_York")|date('d/m/Y H:i:s P', false) }} {{ date(date, "America/New_York")|date('d/m/Y H:i:s P', false) }}
{{ date(timezone="America/New_York", date=date)|date('d/m/Y H:i:s P', false) }} {{ date(timezone="America/New_York", date=date)|date('d/m/Y H:i:s P', false) }}
{{ date(timezone: "America/New_York", date: date)|date('d/m/Y H:i:s P', false) }}
--DATA-- --DATA--
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
return ['date' => mktime(13, 45, 0, 10, 4, 2010)] return ['date' => mktime(13, 45, 0, 10, 4, 2010)]
--EXPECT-- --EXPECT--
04/10/2010 09:45:00 -04:00 04/10/2010 09:45:00 -04:00
04/10/2010 09:45:00 -04:00 04/10/2010 09:45:00 -04:00
04/10/2010 09:45:00 -04:00