Lines Matching refs:to

4 This chapter describes the API to Twig and not the template language. It will
5 be most useful as reference to those implementing the template interface to
12 ``\Twig\Environment``). Instances of this class are used to store the
13 configuration and extensions, and are used to load templates from the file
17 initialization and use that to load templates. In some cases it's however
18 useful to have multiple environments side by side, if different configurations
21 The simplest way to configure Twig to load templates for your application
24 require_once '/path/to/lib/Twig/Autoloader.php';
27 $loader = new \Twig\Loader\FilesystemLoader('/path/to/templates');
29 'cache' => '/path/to/compilation_cache',
33 that looks up the templates in the ``/path/to/templates/`` folder. Different
34 loaders are available and you can also write your own if you want to load
41 the compiled templates to avoid the parsing phase for sub-sequent
42 requests. It is very different from the cache you might want to add for
65 The ``display()`` method is a shortcut to output the template directly.
72 The possibility to render blocks from the API was added in Twig 1.28.
93 When set to ``true``, the generated templates have a
94 ``__toString()`` method that you can use to display the generated nodes
95 (default to ``false``).
97 * ``charset`` *string* (defaults to ``utf-8``)
101 * ``base_template_class`` *string* (defaults to ``\Twig\Template``)
103 The base template class to use for generated
108 An absolute path where to store the compiled templates, or
109 ``false`` to disable caching (which is the default).
113 When developing with Twig, it's useful to recompile the
120 If set to ``false``, Twig will silently ignore invalid
122 replace them with a ``null`` value. When set to ``true``, Twig throws an
123 exception instead (default to ``false``).
127 If set to ``true``, HTML auto-escaping will be enabled by
128 default for all templates (default to ``true``).
130 As of Twig 1.8, you can set the escaping strategy to use (``html``, ``js``,
131 ``false`` to disable).
133 As of Twig 1.9, you can set the escaping strategy to use (``css``, ``url``,
135 return the escaping strategy to use -- the callback cannot be a function name
136 to avoid collision with built-in escaping strategies).
138 As of Twig 1.17, the ``filename`` escaping strategy (renamed to ``name`` as
139 of Twig 1.27) determines the escaping strategy to use for a template based on
145 A flag that indicates which optimizations to apply
146 (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to
179 can find templates in folders on the file system and is the preferred way to
189 ``$templateDir1`` and if they do not exist, it will fallback to look for them
198 The filesystem loader also supports namespaced templates. This allows to group
228 of strings bound to template names::
245 don't want to see your cache grows out of control, you need to take care
251 ``\Twig\Loader\ChainLoader`` delegates the loading of templates to other loaders::
287 * @param string $name string The name of the template to load
291 …* @deprecated since 1.27 (to be removed in 2.0), implement \Twig\Loader\SourceContextLoaderInterfa…
296 * Gets the cache key to use for the cache for a given template name.
298 * @param string $name string The name of the template to load
319 ``\Twig\Loader\SourceContextLoaderInterface`` to avoid deprecation notices.
324 to make your loader faster when used with the chain loader.
329 Twig extensions are packages that add new features to Twig. Using an
339 to escape/unescape blocks of code.
341 * *Twig_Extension_Sandbox*: Adds a sandbox mode to the default Twig
342 environment, making it safe to evaluate untrusted code.
349 The core, escaper, and optimizer extensions do not need to be added to the
359 Read the chapter about extending Twig to learn how to create your own
375 The ``escaper`` extension adds automatic output escaping to Twig. It defines a
384 If set to ``html``, all variables in templates are escaped (using the ``html``
439 {{ var|upper }} {# is equivalent to {{ var|upper|escape }} #}
473 The ``sandbox`` extension can be used to evaluate untrusted code. Access to
476 ``\Twig\Sandbox\SecurityPolicy``. This class allows you to white-list some
492 able to call the ``getTitle()`` and ``getBody()`` methods on ``Article``
537 file_put_contents('/path/to/profile.prof', $dumper->dump($profile));
539 Upload the profile to visualize it (create a `free account
544 blackfire --slot=7 upload /path/to/profile.prof
554 to enable by passing them to the constructor::
581 * ``\Twig\Error\SyntaxError``: Thrown to tell the user that there is a problem with