mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Document Twig vs PHP types
This commit is contained in:
+18
-2
@@ -76,8 +76,24 @@ Twig templates have access to variables provided by the PHP application and
|
|||||||
variables created in templates via the :doc:`set <tags/set>` tag. These
|
variables created in templates via the :doc:`set <tags/set>` tag. These
|
||||||
variables can be manipulated and displayed in the template.
|
variables can be manipulated and displayed in the template.
|
||||||
|
|
||||||
Use a dot (``.``) to access attributes of a variable (methods, properties
|
Twig tries to abstract PHP types as much as possible and works with a few basic
|
||||||
or constants of a PHP object, or items of a PHP array):
|
types, supported by ``filters``, ``functions``, and ``tests`` among others:
|
||||||
|
|
||||||
|
=================== ===============================
|
||||||
|
Twig Type PHP Type
|
||||||
|
=================== ===============================
|
||||||
|
string A string or a Stringable object
|
||||||
|
number An integer or a float
|
||||||
|
boolean ``true`` or ``false``
|
||||||
|
null ``null``
|
||||||
|
iterable (mapping) An array
|
||||||
|
iterable (sequence) An array
|
||||||
|
iterable (object) An iterable object
|
||||||
|
object An object
|
||||||
|
=================== ===============================
|
||||||
|
|
||||||
|
The ``iterable`` and ``object`` types expose attributes you can access via the
|
||||||
|
dot (``.``) operator:
|
||||||
|
|
||||||
.. code-block:: twig
|
.. code-block:: twig
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user