Lines Matching refs:is

24     Twig won't be able to recompile your templates when the PHP code is
48 That works, but using a tag for ``lipsum`` is not a good idea for at least
51 * ``lipsum`` is not a language construct;
53 * The tag is not flexible as you cannot use it in an expression:
70 generate (so, ``40`` is an argument of the filter, not the value we want to
79 Here we go. For this specific example, the creation of a function is the
80 extension point to use. And you can use it anywhere an expression is accepted:
115 A global variable is like any other template variable, except that it's
130 A filter is a regular PHP function or an object method that takes the left
134 Defining a filter is as easy as associating the filter name with a PHP
142 associated with the ``lower`` filter. The ``lower`` filter is a built-in Twig
143 filter, and it is simply mapped to the PHP ``strtolower()`` function. After
144 compilation, the generated PHP code is roughly equivalent to:
150 As you can see, the ``'TWIG'`` string is passed as a first argument to the PHP
160 argument, and the compiled code is equivalent to:
169 `rot13`_ transformation of a string. Here is an example of its usage and the
178 Adding a filter is as simple as calling the ``addFilter()`` method on the
184 The second argument of ``addFilter()`` is an instance of ``Twig_Filter``.
185 Here, we use ``Twig_Filter_Function`` as the filter is a PHP function. The
186 first argument passed to the ``Twig_Filter_Function`` constructor is the name
205 As you can see, the ``prefix`` argument of the filter is passed as an extra
208 Adding this filter is as easy as before::
246 If automatic escaping is enabled, the output of the filter may be escaped
253 Some filters may need to work on input that is already escaped or safe, for
255 case, set the ``pre_escape`` option to escape the input data before it is run
266 A filter name containing the special ``*`` character is a dynamic filter as
297 A function is a regular PHP function or an object method that can be called from
305 associated with the ``constant`` function. The ``constant`` function is a built-in Twig
306 function, and it is simply mapped to the PHP ``constant()`` function. After
307 compilation, the generated PHP code is roughly equivalent to:
313 Adding a function is similar to adding a filter. This can be done by calling the
321 // $this is an object that implements \Twig\Extension\ExtensionInterface.
333 A function name containing the special ``*`` character is a dynamic function
364 One of the most exciting feature of a template engine like Twig is the
365 possibility to define new language constructs. This is also the most complex
381 The ``set`` tag is part of the Core extension and as such is always
382 available. The built-in version is slightly more powerful and supports
397 Adding a tag is as simple as calling the ``addTokenParser`` method on the
430 The ``parse()`` method is invoked whenever the parser encounters a ``set``
432 ``Project_Set_Node`` calls creating is explained in the next section).
434 The parsing process is simplified thanks to a bunch of methods you can call
442 the current token is of a particular type or value (or both). The value may be an
446 type/value a syntax error is thrown. Otherwise, if the type and value are correct,
447 the token is returned and the stream moves to the next token.
451 Parsing expressions is done by calling the ``parseExpression()`` like we did for
456 Reading the existing ``TokenParser`` classes is the best way to learn all
462 The ``Project_Set_Node`` class itself is rather simple::
487 * ``raw()``: Writes the given string as is.
511 The main motivation for writing an extension is to move often used code into a
516 Creating an extension also makes for a better separation of code that is
520 Most of the time, it is useful to create a single extension for your project,
525 When packaging your code into an extension, Twig is smart enough to
527 ``auto_reload`` is enabled).
534 An extension is a class that implements the following interface::
541 * This is where you can load some file that contains filter functions for instance.
725 The first argument of the ``Twig_Filter_Method`` constructor is always
726 ``$this``, the current extension object. The second one is the name of the
729 Using methods for filters is a great way to package your filter without
762 is as simple as registering the ``MyCoreExtension`` extension by calling the
786 ``Project_Set_TokenParser`` class. The ``Project_Set_TokenParser`` class is
792 The ``getOperators()`` methods allows to add new operators. Here is how to add