Lines Matching refs:a

10 A template is simply a text file. It can generate any text-based format (HTML,
11 XML, CSV, LaTeX, etc.). It doesn't have a specific extension, ``.html`` or
18 Below is a minimal template that illustrates a few basics. We will cover further
31 <li><a href="{{ item.href }}">{{ item.caption }}</a></li>
65 from a browser; it supports all versions of Twig.
72 too. The visual representation of a variable depends heavily on the application providing
75 You can use a dot (``.``) to access attributes of a variable (methods or
76 properties of a PHP object, or items of a PHP array), or the so-called
99 If a variable or attribute does not exist, you will receive a ``null`` value
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
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;
114 * if not, return a ``null`` value.
118 * check if ``foo`` is an array and ``bar`` a valid element;
119 * if not, return a ``null`` value.
123 If you want to access a dynamic attribute of a variable, use the
151 variable by a pipe symbol (``|``) and may have optional arguments in
163 example will join a list by commas:
169 To apply a filter on a section of code, wrap it in the
187 For instance, the ``range`` function returns a list containing an arithmetic
232 {# or skip the format value by using a named argument for the time zone #}
244 Each function and filter documentation page has a section where the names
250 A control structure refers to all those things that control the flow of a
255 For example, to display a list of users provided in a variable called
284 To comment-out part of a line in a template, use the comment syntax ``{# ...
299 The :doc:`include<functions/include>` function is useful to include a template
320 filename. You can access templates in subdirectories with a slash:
332 allows you to build a base "skeleton" template that contains all the common
339 Let's define a base template, ``base.html``, which defines a simple HTML
340 skeleton document that you might use for a simple two-column page:
356 &copy; Copyright 2011 by <a href="http://domain.invalid/">you</a>.
364 template engine that a child template may override those portions of the
422 When generating HTML from templates, there's always a risk that a variable
459 Whether automatic escaping is enabled or not, you can mark a section of a
484 used and you want to use ``{{`` as raw string in the template and not start a
485 variable you have to use a trick.
487 The easiest way is to output the variable delimiter (``{{``) by using a variable
494 For bigger sections it makes sense to mark a block
506 A macro is defined via the :doc:`macro<tags/macro>` tag. Here is a small example
507 (subsequently called ``forms.html``) of a macro that renders a form element:
524 Alternatively, you can import individual macro names from a template into the
538 A default value can also be defined for macro arguments when not provided in a
547 If extra positional arguments are passed to a macro call, they end up in the
548 special ``varargs`` variable as a list of values.
587 * ``"Hello World"``: Everything between two double or single quotes is a
588 string. They are useful whenever you need a string in the template (for
590 a template). A string can contain a delimiter if it is preceded by a
591 backslash (``\``) -- like in ``'It\'s good'``. If the string contains a
596 writing the number down. If a dot is present the number is a float,
599 * ``["foo", "bar"]``: Arrays are defined by a sequence of expressions
600 separated by a comma (``,``) and wrapped with squared brackets (``[]``).
602 * ``{"foo": "bar"}``: Hashes are defined by a list of keys and values
603 separated by a comma (``,``) and wrapped with curly braces (``{}``):
624 when a variable does not exist. ``none`` is an alias for ``null``.
649 * ``/``: Divides two numbers. The returned value will be a floating point
676 * ``not``: Negates a statement.
694 You can also check if a string ``starts with`` or ``ends with`` another
732 You can use this filter to perform a containment test on strings, arrays,
735 To perform a negative test, use the ``not in`` operator:
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 #}
782 * ``|``: Applies a filter.
784 * ``..``: Creates a sequence based on the operand before and after the operator
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.)
863 In addition to the spaceless tag you can also control whitespace on a per tag
880 of a tag:
894 If you are looking for new tags, filters, or functions, have a look at the Twig official