Add config to enable Twig strict_variables (#3370)
Adds the cms.enableTwigStrictVariables config option to enable strict_variables in Twig for debugging purposes. See https://twig.symfony.com/doc/2.x/api.html#environment-options. Credit to @matteotrubini
This commit is contained in:
parent
cf01254b2b
commit
678916854e
|
|
@ -347,4 +347,19 @@ return [
|
|||
|
||||
'forceBytecodeInvalidation' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Twig Strict Variables
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If strict_variables is disabled, Twig will silently ignore invalid
|
||||
| variables (variables and or attributes/methods that do not exist) and
|
||||
| replace them with a null value. When enabled, Twig throws an exception
|
||||
| instead. If set to null, it is enabled when debug mode (app.debug) is
|
||||
| enabled.
|
||||
|
|
||||
*/
|
||||
|
||||
'enableTwigStrictVariables' => false,
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -488,11 +488,14 @@ class Controller
|
|||
|
||||
$useCache = !Config::get('cms.twigNoCache');
|
||||
$isDebugMode = Config::get('app.debug', false);
|
||||
$strictVariables = Config::get('cms.enableTwigStrictVariables', false);
|
||||
$strictVariables = is_null($strictVariables) ? $isDebugMode : $strictVariables;
|
||||
$forceBytecode = Config::get('cms.forceBytecodeInvalidation', false);
|
||||
|
||||
$options = [
|
||||
'auto_reload' => true,
|
||||
'debug' => $isDebugMode,
|
||||
'strict_variables' => $strictVariables,
|
||||
];
|
||||
|
||||
if ($useCache) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue