mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-06 23:48:50 +00:00
1da95371d1a48bfb0ecd027322ea064f35631ca5
This PR was merged into the 1.x branch.
Discussion
----------
document support for defining default argument values in the macro tag
The `macro` tag documentation reads
> Macros differ from native PHP functions in a few ways:
> - Default argument values are defined by using the default filter in the macro body
and provides the example
```twig
{% macro input(name, value, type, size) %}
<input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
{% endmacro %}
```
The implication is that native PHP function-like default argument value definition is not supported.
v1.12 added support for
```twig
{% macro input1(name, value, type = 'text', size = 20) %}
<input type="{{ type }}" name="{{ name }}" value="{{ value|e }}" size="{{ size }}" />
{% endmacro %}
```
This updates the documentation to cover both ways of defining default argument values.
Commits
-------
40c7553a document support for defining default argument values in the macro tag
…
Twig, the flexible, fast, and secure template language for PHP ============================================================== Twig is a template language for PHP, released under the new BSD license (code and documentation). Twig uses a syntax similar to the Django and Jinja template languages which inspired the Twig runtime environment. More Information ---------------- Read the `documentation`_ for more information. .. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%