ユーザ用ツール

サイト用ツール


サイドバー

このページの翻訳:



最近の更新



Tag Cloud

11_php:01_twig:02_autoescape

文書の過去の版を表示しています。


02 自動エスケープ(autoescape)

twigではクロスサイトスクリプト防止の為、自動エスケープがデフォルトで有効になっています。

1.twig側で設定する場合

「autoescape false」で囲んであげると、autoescapeを無効にできます。

{% autoescape false %}
{{ vm.memo|escape|replace({'\n':'<br />'}) }}
{% endautoescape %}

2.コントローラ側で設定する場合

registerの時に「'autoescape' ⇒ false」としてあげるとautoescapeを無効にできます。

// autoescapeを無効にする。
$app->register(new Silex\Provider\TwigServiceProvider(), array(
	'twig.path' => __DIR__ . '/views',
	'twig.options' => array(
	'autoescape' => false,
	),
));
11_php/01_twig/02_autoescape.1404361732.txt.gz · 最終更新: 2014/07/03 13:28 by matsui