3c921b1cf983b954b329b8eb4a83a810ce269a9a
[yaffs-website] / vendor / twig / twig / doc / functions / source.rst
1 ``source``
2 ==========
3
4 .. versionadded:: 1.15
5     The ``source`` function was added in Twig 1.15.
6
7 .. versionadded:: 1.18.3
8     The ``ignore_missing`` flag was added in Twig 1.18.3.
9
10 The ``source`` function returns the content of a template without rendering it:
11
12 .. code-block:: jinja
13
14     {{ source('template.html') }}
15     {{ source(some_var) }}
16
17 When you set the ``ignore_missing`` flag, Twig will return an empty string if
18 the template does not exist:
19
20 .. code-block:: jinja
21
22     {{ source('template.html', ignore_missing = true) }}
23
24 The function uses the same template loaders as the ones used to include
25 templates. So, if you are using the filesystem loader, the templates are looked
26 for in the paths defined by it.
27
28 Arguments
29 ---------
30
31 * ``name``: The name of the template to read
32 * ``ignore_missing``: Whether to ignore missing templates or not