Lines Matching refs:is

10 A template is simply a text file. It can generate any text-based format (HTML,
15 values when the template is evaluated, and **tags**, which control the logic
18 Below is a minimal template that illustrates a few basics. We will cover further
41 one is used to execute statements such as for-loops, the latter prints the
64 Also, `TwigFiddle`_ is an online service that allows you to execute Twig templates
100 when the ``strict_variables`` option is set to ``false``; alternatively, if ``strict_variables``
101 is set, Twig will throw an error (see :ref:`environment options<environment_options>`).
108 * check if ``foo`` is an array and ``bar`` a valid element;
109 * if not, and if ``foo`` is an object, check that ``bar`` is a valid property;
110 * if not, and if ``foo`` is an object, check that ``bar`` is a valid method
111 (even if ``bar`` is the constructor - use ``__construct()`` instead);
112 * if not, and if ``foo`` is an object, check that ``getBar`` is a valid method;
113 * if not, and if ``foo`` is an object, check that ``isBar`` is a valid method;
118 * check if ``foo`` is an array and ``bar`` a valid element;
152 parentheses. Multiple filters can be chained. The output of one filter is
229 …{# the first argument is the date format, which defaults to the global date format if null is pass…
285 #}``. This is useful for debugging or to add information for other template
299 The :doc:`include<functions/include>` function is useful to include a template
316 The included template ``render_box.html`` is able to access the ``box`` variable.
331 The most powerful part of Twig is template inheritance. Template inheritance
336 Sounds complicated but it is very basic. It's easier to understand it by
363 child templates can fill in. All the ``block`` tag does is to tell the
387 The :doc:`extends<tags/extends>` tag is the key here. It tells the template
393 value from the parent template is used instead.
416 with the help of the :doc:`use<tags/use>` tag. This is an advanced feature
427 Twig supports both, automatic escaping is enabled by default.
435 If manual escaping is enabled, it is **your** responsibility to escape
459 Whether automatic escaping is enabled or not, you can mark a section of a
482 It is sometimes desirable or even necessary to have Twig ignore parts it would
483 otherwise handle as variables or blocks. For example if the default syntax is
487 The easiest way is to output the variable delimiter (``{{``) by using a variable
506 A macro is defined via the :doc:`macro<tags/macro>` tag. Here is a small example
560 The operator precedence is as follows, with the lowest-precedence operators
564 ``*``, ``/``, ``//``, ``%``, ``is`` (tests), ``**``, ``??``, ``|``
587 * ``"Hello World"``: Everything between two double or single quotes is a
590 a template). A string can contain a delimiter if it is preceded by a
596 writing the number down. If a dot is present the number is a float,
623 * ``null``: ``null`` represents no specific value. This is the value returned
624 when a variable does not exist. ``none`` is an alias for ``null``.
635 but string interpolation is only supported in double-quoted strings.
640 Twig allows you to calculate with values. This is rarely useful in templates
644 1 + 1 }}`` is ``2``.
646 * ``-``: Subtracts the second number from the first one. ``{{ 3 - 2 }}`` is
650 number. ``{{ 1 / 2 }}`` is ``{{ 0.5 }}``.
652 * ``%``: Calculates the remainder of an integer division. ``{{ 11 % 7 }}`` is
656 // 7 }}`` is ``2``, ``{{ -20 // 7 }}`` is ``-3`` (this is just syntactic
674 * ``or``: Returns true if the left or the right operand is true.
720 It returns ``true`` if the left operand is contained in the right:
741 {# is equivalent to #}
747 The ``is`` operator performs tests. Tests can be used to test a variable against
748 a common expression. The right operand is name of the test:
752 {# find out if a variable is odd #}
754 {{ name is odd }}
760 {% if post.status is constant('Post::PUBLISHED') %}
762 Tests can be negated by using the ``is not`` operator:
766 {% if post.status is not constant('Post::PUBLISHED') %}
768 {# is equivalent to #}
769 {% if not (post.status is constant('Post::PUBLISHED')) %}
785 (this is just syntactic sugar for the :doc:`range<functions/range>` function):
802 " ~ name ~ "!" }}`` would return (assuming ``name`` is ``'John'``) ``Hello
814 {{ foo ?: 'no' }} is the same as {{ foo ? foo : 'no' }}
815 {{ foo ? 'yes' }} is the same as {{ foo ? 'yes' : '' }}
821 {# returns the value of foo if it is defined and not null, 'no' otherwise #}
831 within a *double-quoted string*. The result of evaluating that expression is
847 The first newline after a template tag is removed automatically (like in PHP.)
848 Whitespace is not further modified by the template engine, so each whitespace
849 (spaces, tabs, newlines etc.) is returned unchanged.
879 for that side of the tag. It is possible to use whitespace trimming on one side