使用Timber启用Twig严格变量

时间:2016-02-20 10:09:19

标签: timber

我正在运行最新版本的Timber(0.22.5)。

有没有办法为Twig启用strict_variables

1 个答案:

答案 0 :(得分:1)

想出来 - 把它贴在你的functions.php文件中:

function theme_configure_twig($twig) {
    $twig->enableStrictVariables();
    return $twig;
}
add_filter('get_twig', 'theme_configure_twig');

请注意,在上文中,$twig指的是Timber的Twig_Environment实例。