mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-17 16:52:49 +00:00
Fix typos in CHANGELOG
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# 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 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
|
||||
|
||||
@@ -105,3 +105,9 @@ standards:
|
||||
true
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
* Use ``:`` instead of ``=`` to separate argument names and values:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{{ data|convert_encoding(from: 'iso-2022-jp', to: 'UTF-8') }}
|
||||
|
||||
@@ -11,13 +11,13 @@ The ``data_uri`` filter generates a URL using the data scheme as defined in
|
||||
{{ source('path_to_image')|data_uri }}
|
||||
|
||||
{# 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 #}
|
||||
{{ '<b>foobar</b>'|data_uri(mime="text/html") }}
|
||||
{{ '<b>foobar</b>'|data_uri(mime: "text/html") }}
|
||||
|
||||
{# 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::
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ By default, the filter uses the current locale. You can pass it explicitly:
|
||||
.. code-block:: twig
|
||||
|
||||
{# 1.000.000,00 € #}
|
||||
{{ '1000000'|format_currency('EUR', locale='de') }}
|
||||
{{ '1000000'|format_currency('EUR', locale: 'de') }}
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ You can tweak the output for the date part and the time part:
|
||||
.. code-block:: twig
|
||||
|
||||
{# 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 #}
|
||||
{{ '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 #}
|
||||
{{ '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``.
|
||||
|
||||
@@ -38,7 +38,7 @@ For greater flexibility, you can even define your own pattern
|
||||
.. code-block:: twig
|
||||
|
||||
{# 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
|
||||
------
|
||||
@@ -48,7 +48,7 @@ By default, the filter uses the current locale. You can pass it explicitly:
|
||||
.. code-block:: twig
|
||||
|
||||
{# 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
|
||||
--------
|
||||
@@ -59,14 +59,14 @@ it by explicitly specifying a timezone:
|
||||
|
||||
.. 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
|
||||
timezone, pass ``false`` as the timezone value:
|
||||
|
||||
.. 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()``::
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ Besides plain numbers, the filter can also format numbers in various styles:
|
||||
.. code-block:: twig
|
||||
|
||||
{# 1,234% #}
|
||||
{{ '12.345'|format_number(style='percent') }}
|
||||
{{ '12.345'|format_number(style: 'percent') }}
|
||||
|
||||
{# twelve point three four five #}
|
||||
{{ '12.345'|format_number(style='spellout') }}
|
||||
{{ '12.345'|format_number(style: 'spellout') }}
|
||||
|
||||
{# 12 sec. #}
|
||||
{{ '12'|format_duration_number }}
|
||||
@@ -85,7 +85,7 @@ By default, the filter uses the current locale. You can pass it explicitly:
|
||||
.. code-block:: twig
|
||||
|
||||
{# 12,345 #}
|
||||
{{ '12.345'|format_number(locale='fr') }}
|
||||
{{ '12.345'|format_number(locale: 'fr') }}
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ and end of a string:
|
||||
|
||||
{# outputs ' I like Twig' #}
|
||||
|
||||
{{ ' I like Twig. '|trim(side='left') }}
|
||||
{{ ' I like Twig. '|trim(side: 'left') }}
|
||||
|
||||
{# outputs 'I like Twig. ' #}
|
||||
|
||||
|
||||
+12
-7
@@ -210,11 +210,16 @@ built-in functions.
|
||||
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
|
||||
|
||||
{% for i in range(low=1, high=10, step=2) %}
|
||||
{% for i in range(low: 1, high: 10, step: 2) %}
|
||||
{{ i }},
|
||||
{% endfor %}
|
||||
|
||||
@@ -227,7 +232,7 @@ the values you pass as arguments:
|
||||
|
||||
{# 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
|
||||
to change the default value:
|
||||
@@ -238,19 +243,19 @@ to change the default value:
|
||||
{{ "now"|date(null, "Europe/Paris") }}
|
||||
|
||||
{# 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
|
||||
case positional arguments must always come before named arguments:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{{ "now"|date('d/m/Y H:i', timezone="Europe/Paris") }}
|
||||
{{ "now"|date('d/m/Y H:i', timezone: "Europe/Paris") }}
|
||||
|
||||
.. tip::
|
||||
|
||||
Each function and filter documentation page has a section where the names
|
||||
of all arguments are listed when supported.
|
||||
Each function, filter, and test documentation page has a section where the
|
||||
names of all supported arguments are listed.
|
||||
|
||||
Control Structure
|
||||
-----------------
|
||||
|
||||
@@ -639,7 +639,7 @@ class ExpressionParser
|
||||
}
|
||||
|
||||
$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) {
|
||||
throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', \get_class($value)), $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
--TEMPLATE--
|
||||
{{ attribute(obj, method) }}
|
||||
{{ attribute(variable=obj, attribute=method) }}
|
||||
{{ attribute(variable: obj, attribute: method) }}
|
||||
{{ attribute(array, item) }}
|
||||
{{ attribute(obj, "bar", ["a", "b"]) }}
|
||||
{{ attribute(obj, "bar", arguments) }}
|
||||
{{ attribute(variable=obj, attribute="bar", arguments=arguments) }}
|
||||
{{ attribute(variable: obj, attribute: "bar", arguments: arguments) }}
|
||||
{{ attribute(obj, method) is defined ? 'ok' : 'ko' }}
|
||||
{{ attribute(obj, nonmethod) is defined ? 'ok' : 'ko' }}
|
||||
--DATA--
|
||||
@@ -14,9 +16,11 @@ return ['obj' => new Twig\Tests\TwigTestFoo(), 'method' => 'foo', 'array' => ['f
|
||||
--EXPECT--
|
||||
foo
|
||||
foo
|
||||
foo
|
||||
bar
|
||||
bar_a-b
|
||||
bar_a-b
|
||||
bar_a-b
|
||||
bar_a-b
|
||||
ok
|
||||
ko
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
--TEMPLATE--
|
||||
{{ 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) }}
|
||||
--DATA--
|
||||
date_default_timezone_set('UTC');
|
||||
return ['date' => mktime(13, 45, 0, 10, 4, 2010)]
|
||||
--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
|
||||
|
||||
Reference in New Issue
Block a user