Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | ``sandbox`` |
| 2 | =========== |
| 3 | |
| 4 | The ``sandbox`` tag can be used to enable the sandboxing mode for an included |
| 5 | template, when sandboxing is not enabled globally for the Twig environment: |
| 6 | |
| 7 | .. code-block:: twig |
| 8 | |
| 9 | {% sandbox %} |
| 10 | {% include 'user.html' %} |
| 11 | {% endsandbox %} |
| 12 | |
| 13 | .. warning:: |
| 14 | |
| 15 | The ``sandbox`` tag is only available when the sandbox extension is |
| 16 | enabled (see the :doc:`Twig for Developers<../api>` chapter). |
| 17 | |
| 18 | .. note:: |
| 19 | |
| 20 | The ``sandbox`` tag can only be used to sandbox an include tag and it |
| 21 | cannot be used to sandbox a section of a template. The following example |
| 22 | won't work: |
| 23 | |
| 24 | .. code-block:: twig |
| 25 | |
| 26 | {% sandbox %} |
| 27 | {% for i in 1..2 %} |
| 28 | {{ i }} |
| 29 | {% endfor %} |
| 30 | {% endsandbox %} |