Lines Matching refs:template

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
32 This will create a template environment with the default settings and a loader
49 To load a template from a Twig environment, call the ``load()`` method which
52 $template = $twig->load('index.html');
59 To render the template with some variables, call the ``render()`` method::
61 echo $template->render(['the' => 'variables', 'go' => 'here']);
65 The ``display()`` method is a shortcut to output the template directly.
67 You can also load and render the template in one fell swoop::
74 If a template defines blocks, they can be rendered individually via the
77 echo $template->renderBlock('block_name', ['the' => 'variables', 'go' => 'here']);
103 The base template class to use for generated
114 template whenever the source code changes. If you don't provide a value for
134 ``html_attr``, or a PHP callback that takes the template name and must
139 of Twig 1.27) determines the escaping strategy to use for a template based on
140 the template filename extension (this strategy does not incur any overhead at
158 All template loaders can cache the compiled templates on the filesystem for
199 your templates under different namespaces which have their own template paths.
227 ``\Twig\Loader\ArrayLoader`` loads a template from a PHP array. It's passed an array
228 of strings bound to template names::
243 should know that a new cache key is generated each time a template content
244 "changes" (the cache key being the source code of the template). If you
265 When looking for a template, Twig will try each loader in turn and it will
266 return as soon as the template is found. When rendering the ``index.html``
267 template from the above example, Twig will load it with ``$loader2`` but the
268 ``base.html`` template will be loaded from ``$loader1``.
285 * Gets the source code of a template, given its name.
287 * @param string $name string The name of the template to load
289 * @return string The template source code
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
305 * Returns true if the template is still fresh.
307 * @param string $name The template name
308 * @param timestamp $time The last modification time of the cached template
313 The ``isFresh()`` method must return ``true`` if the current cached template
409 * Literals (integers, booleans, arrays, ...) used in the template directly as
502 untrusted template code by using the ``sandbox`` tag:
530 A profile contains information about time and memory consumption for template,
582 the template syntax.
587 * ``\Twig\Error\LoaderError``: Thrown when an error occurs during template loading.
590 method is called in a sandboxed template.