values when the template is evaluated, and **tags**, which control the logic
of the template.
-Below is a minimal template that illustrates a few basics. We will cover the
+Below is a minimal template that illustrates a few basics. We will cover further
details later on:
.. code-block:: html+jinja
Variables
---------
-The application passes variables to the templates you can mess around in the
-template. Variables may have attributes or elements on them you can access
-too. How a variable looks like heavily depends on the application providing
-those.
+The application passes variables to the templates for manipulation in the
+template. Variables may have attributes or elements you can access,
+too. The visual representation of a variable depends heavily on the application providing
+it.
You can use a dot (``.``) to access attributes of a variable (methods or
properties of a PHP object, or items of a PHP array), or the so-called
.. note::
It's important to know that the curly braces are *not* part of the
- variable but the print statement. If you access variables inside tags
- don't put the braces around.
+ variable but the print statement. When accessing variables inside tags,
+ don't put the braces around them.
-If a variable or attribute does not exist, you will get back a ``null`` value
-when the ``strict_variables`` option is set to ``false``, otherwise Twig will
-throw an error (see :ref:`environment options<environment_options>`).
+If a variable or attribute does not exist, you will receive a ``null`` value
+when the ``strict_variables`` option is set to ``false``; alternatively, if ``strict_variables``
+is set, Twig will throw an error (see :ref:`environment options<environment_options>`).
.. sidebar:: Implementation
- For convenience sake ``foo.bar`` does the following things on the PHP
+ For convenience's sake ``foo.bar`` does the following things on the PHP
layer:
* check if ``foo`` is an array and ``bar`` a valid element;
.. note::
- If you want to get a dynamic attribute on a variable, use the
+ If you want to access a dynamic attribute of a variable, use the
:doc:`attribute<functions/attribute>` function instead.
Global Variables
{{ list|join(', ') }}
-To apply a filter on a section of code, wrap it with the
+To apply a filter on a section of code, wrap it in the
:doc:`filter<tags/filter>` tag:
.. code-block:: jinja
This text becomes uppercase
{% endfilter %}
-Go to the :doc:`filters<filters/index>` page to learn more about the built-in
+Go to the :doc:`filters<filters/index>` page to learn more about built-in
filters.
Functions
{# the first argument is the date format, which defaults to the global date format if null is passed #}
{{ "now"|date(null, "Europe/Paris") }}
- {# or skip the format value by using a named argument for the timezone #}
+ {# or skip the format value by using a named argument for the time zone #}
{{ "now"|date(timezone="Europe/Paris") }}
You can also use both positional and named arguments in one call, in which