Lines Matching refs:tag

41 You can use a ``lipsum`` *tag*:
47 That works, but using a tag for ``lipsum`` is not a good idea for at least
51 * The tag outputs something;
52 * The tag is not flexible as you cannot use it in an expression:
106 *tag* complex rare DSL language construct
389 Most of the time though, a tag is not needed:
391 * If your tag generates some output, use a **function** instead.
393 * If your tag modifies some content and returns it, use a **filter** instead.
395 For instance, if you want to create a tag that converts a Markdown formatted
403 :doc:`filter <tags/filter>` tag:
411 Much better than creating a tag as you can **compose** filters.
414 * If your tag does not output anything, but only exists because of a side
416 :doc:`filter <tags/do>` tag.
418 For instance, if you want to create a tag that logs text, create a ``log``
419 function instead and call it via the :doc:`do <tags/do>` tag:
425 If you still want to create a tag for a new language construct, great!
427 Let's create a simple ``set`` tag that allows the definition of simple
428 variables from within a template. The tag can be used like follows:
440 The ``set`` tag is part of the Core extension and as such is always
445 Three steps are needed to define a new tag:
451 * Registering the tag.
453 Registering a new tag
456 Adding a tag is as simple as calling the ``addTokenParser`` method on the
488 The ``getTag()`` method must return the tag we want to parse, here ``set``.
491 tag. It should return a ``\Twig\Node\Node`` instance that represents the node (the
512 the ``set`` tag.
526 …ic function __construct($name, \Twig\Node\Expression\AbstractExpression $value, $line, $tag = null)
528 parent::__construct(['value' => $value], ['name' => $name], $line, $tag);
751 Adding a tag in an extension can be done by overriding the
765 In the above code, we have added a single new tag, defined by the
767 responsible for parsing the tag and compiling it to PHP.