我正在运行最新版本的 Timber (0.22.5)。
有没有办法可以strict_variables为 Twig 启用?
想通了——把它放在你的functions.php文件中:
function theme_configure_twig($twig) {
$twig->enableStrictVariables();
return $twig;
}
add_filter('get_twig', 'theme_configure_twig');
请注意,在上面,$twig是指 Timber 的Twig_Environment.