mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
tweaked docs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.19.0 (2015-XX-XX)
|
||||
|
||||
* added support for variadic filters, functions, and tests
|
||||
* added support for extra positional arguments in macros
|
||||
* added ignore_missing flag to the source function
|
||||
* fixed batch filter with zero items
|
||||
|
||||
+9
-9
@@ -230,16 +230,16 @@ Variadic Filters
|
||||
.. versionadded:: 1.19
|
||||
Support for variadic filters was added in Twig 1.19.
|
||||
|
||||
If you want to pass a variable number of positional or named arguments to the filter,
|
||||
set the ``is_variadic`` option to ``true``; Twig will pass the array of arbitrary arguments
|
||||
as the last argument to the filter call that is defined as an array with an empty default value::
|
||||
When a filter should accept an arbitrary number of arguments, set the
|
||||
``is_variadic`` option to ``true``; Twig will pass the extra arguments as the
|
||||
last argument to the filter call as an array::
|
||||
|
||||
$filter = new Twig_SimpleFilter('thumbnail', function ($file, array $options = array()) {
|
||||
...
|
||||
// ...
|
||||
}, array('is_variadic' => true));
|
||||
|
||||
The named arguments passed to the variadic filter cannot be checked if they are valid or not
|
||||
as if they are not valid, they will end up in the option array.
|
||||
Be warned that named arguments passed to a variadic filter cannot be checked
|
||||
for validity as they will automatically end up in the option array.
|
||||
|
||||
Dynamic Filters
|
||||
~~~~~~~~~~~~~~~
|
||||
@@ -348,9 +348,9 @@ The ``node`` sub-node will contain an expression of ``my_value``. Node-based
|
||||
tests also have access to the ``arguments`` node. This node will contain the
|
||||
various other arguments that have been provided to your test.
|
||||
|
||||
If you want to pass a variable number of positional or named arguments to the test,
|
||||
set the ``is_variadic`` option to ``true``. Tests also support dynamic name feature
|
||||
as filters and functions.
|
||||
If you want to pass a variable number of positional or named arguments to the
|
||||
test, set the ``is_variadic`` option to ``true``. Tests also support dynamic
|
||||
name feature as filters and functions.
|
||||
|
||||
Tags
|
||||
----
|
||||
|
||||
@@ -238,21 +238,6 @@ case positional arguments must always come before named arguments:
|
||||
Each function and filter documentation page has a section where the names
|
||||
of all arguments are listed when supported.
|
||||
|
||||
Variadic Arguments
|
||||
------------------
|
||||
|
||||
.. versionadded:: 1.19
|
||||
Support for variadic arguments was added in Twig 1.19.
|
||||
|
||||
The variadic filter, function or test can accept any arbitrary positional or named arguments:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ "path/to/image.png"|thumbnail(size=[32, 32], mode=outbound, quality=90, format="jpg") }}
|
||||
|
||||
The named arguments passed to the variadic filter, function or test cannot be checked if they are valid or not
|
||||
as if they are not valid, they will end up in the option array.
|
||||
|
||||
Control Structure
|
||||
-----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user