]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/doc/functions/template_from_string.rst
twig implementation
[github/wallabag/wallabag.git] / vendor / twig / twig / doc / functions / template_from_string.rst
1 ``template_from_string``
2 ========================
3
4 .. versionadded:: 1.11
5 The template_from_string function was added in Twig 1.11.
6
7 The ``template_from_string`` function loads a template from a string:
8
9 .. code-block:: jinja
10
11 {{ include(template_from_string("Hello {{ name }}") }}
12 {{ include(template_from_string(page.template)) }}
13
14 .. note::
15
16 The ``template_from_string`` function is not available by default. You
17 must add the ``Twig_Extension_StringLoader`` extension explicitly when
18 creating your Twig environment::
19
20 $twig = new Twig_Environment(...);
21 $twig->addExtension(new Twig_Extension_StringLoader());
22
23 .. note::
24
25 Even if you will probably always use the ``template_from_string`` function
26 with the ``include`` function, you can use it with any tag or function that
27 takes a template as an argument (like the ``embed`` or ``extends`` tags).
28
29 Arguments
30 ---------
31
32 * ``template``: The template