mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
Fixed a number of grammatical errors and the like
This commit is contained in:
+15
-15
@@ -15,7 +15,7 @@ A template contains **variables** or **expressions**, which get replaced with
|
|||||||
values when the template is evaluated, and **tags**, which control the logic
|
values when the template is evaluated, and **tags**, which control the logic
|
||||||
of the template.
|
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:
|
details later on:
|
||||||
|
|
||||||
.. code-block:: html+jinja
|
.. code-block:: html+jinja
|
||||||
@@ -62,10 +62,10 @@ Many IDEs support syntax highlighting and auto-completion for Twig:
|
|||||||
Variables
|
Variables
|
||||||
---------
|
---------
|
||||||
|
|
||||||
The application passes variables to the templates you can mess around in the
|
The application passes variables to the templates for manipulation in the
|
||||||
template. Variables may have attributes or elements on them you can access
|
template. Variables may have attributes or elements you can access,
|
||||||
too. How a variable looks like heavily depends on the application providing
|
too. The visual representation of a variable depends heavily on the application providing
|
||||||
those.
|
it.
|
||||||
|
|
||||||
You can use a dot (``.``) to access attributes of a variable (methods or
|
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
|
properties of a PHP object, or items of a PHP array), or the so-called
|
||||||
@@ -88,16 +88,16 @@ access the variable attribute:
|
|||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
It's important to know that the curly braces are *not* part of the
|
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
|
variable but the print statement. When accessing variables inside tags,
|
||||||
don't put the braces around.
|
don't put the braces around them.
|
||||||
|
|
||||||
If a variable or attribute does not exist, you will get back a ``null`` value
|
If a variable or attribute does not exist, you will receive a ``null`` value
|
||||||
when the ``strict_variables`` option is set to ``false``, otherwise Twig will
|
when the ``strict_variables`` option is set to ``false``; alternatively, if ``strict_variables``
|
||||||
throw an error (see :ref:`environment options<environment_options>`).
|
is set, Twig will throw an error (see :ref:`environment options<environment_options>`).
|
||||||
|
|
||||||
.. sidebar:: Implementation
|
.. 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:
|
layer:
|
||||||
|
|
||||||
* check if ``foo`` is an array and ``bar`` a valid element;
|
* check if ``foo`` is an array and ``bar`` a valid element;
|
||||||
@@ -115,7 +115,7 @@ throw an error (see :ref:`environment options<environment_options>`).
|
|||||||
|
|
||||||
.. note::
|
.. 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.
|
:doc:`attribute<functions/attribute>` function instead.
|
||||||
|
|
||||||
Global Variables
|
Global Variables
|
||||||
@@ -161,7 +161,7 @@ example will join a list by commas:
|
|||||||
|
|
||||||
{{ list|join(', ') }}
|
{{ 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:
|
:doc:`filter<tags/filter>` tag:
|
||||||
|
|
||||||
.. code-block:: jinja
|
.. code-block:: jinja
|
||||||
@@ -170,7 +170,7 @@ To apply a filter on a section of code, wrap it with the
|
|||||||
This text becomes uppercase
|
This text becomes uppercase
|
||||||
{% endfilter %}
|
{% 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.
|
filters.
|
||||||
|
|
||||||
Functions
|
Functions
|
||||||
@@ -222,7 +222,7 @@ to change the default value:
|
|||||||
{# the first argument is the date format, which defaults to the global date format if null is passed #}
|
{# the first argument is the date format, which defaults to the global date format if null is passed #}
|
||||||
{{ "now"|date(null, "Europe/Paris") }}
|
{{ "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") }}
|
{{ "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
|
||||||
|
|||||||
Reference in New Issue
Block a user