sandbox

The sandbox tag can be used to enable the sandboxing mode for an included template, when sandboxing is not enabled globally for the Twig environment:

Twig 環境でサンドボックスがグローバルに有効になっていない場合は、sandbox タグを使用して、含まれるテンプレートのサンドボックス モードを有効にすることができます。
1
2
3
{% sandbox %}
    {% include 'user.html' %}
{% endsandbox %}

Warning

警告

The sandbox tag is only available when the sandbox extension is enabled (see the Twig for Developers chapter).

サンドボックス タグは、サンドボックス拡張機能が有効になっている場合にのみ使用できます (Twig for Developers の章を参照してください)。

Note

ノート

The sandbox tag can only be used to sandbox an include tag and it cannot be used to sandbox a section of a template. The following example won't work:

サンドボックス タグは、インクルード タグをサンドボックス化するためにのみ使用でき、テンプレートのセクションをサンドボックス化するためには使用できません。次の例は機能しません。
1
2
3
4
5
{% sandbox %}
    {% for i in 1..2 %}
        {{ i }}
    {% endfor %}
{% endsandbox %}