Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | ``source`` |
| 2 | ========== |
| 3 | |
| 4 | The ``source`` function returns the content of a template without rendering it: |
| 5 | |
| 6 | .. code-block:: twig |
| 7 | |
| 8 | {{ source('template.html') }} |
| 9 | {{ source(some_var) }} |
| 10 | |
| 11 | When you set the ``ignore_missing`` flag, Twig will return an empty string if |
| 12 | the template does not exist: |
| 13 | |
| 14 | .. code-block:: twig |
| 15 | |
| 16 | {{ source('template.html', ignore_missing = true) }} |
| 17 | |
| 18 | The function uses the same template loaders as the ones used to include |
| 19 | templates. So, if you are using the filesystem loader, the templates are looked |
| 20 | for in the paths defined by it. |
| 21 | |
| 22 | Arguments |
| 23 | --------- |
| 24 | |
| 25 | * ``name``: The name of the template to read |
| 26 | * ``ignore_missing``: Whether to ignore missing templates or not |