This commit is contained in:
2018-09-19 21:43:25 +02:00
parent 1c407a4328
commit f9d3d02e74
482 changed files with 31736 additions and 9897 deletions
+10 -7
View File
@@ -113,7 +113,10 @@ class Twig
$params['cache'] = new \Twig_Cache_Filesystem($cachePath, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION);
}
if (!empty($this->autoescape)) {
if (!$config->get('system.strict_mode.twig_compat', true)) {
// Force autoescape on for all files if in strict mode.
$params['autoescape'] = true;
} elseif (!empty($this->autoescape)) {
$params['autoescape'] = $this->autoescape;
}
@@ -122,10 +125,10 @@ class Twig
if ($config->get('system.twig.undefined_functions')) {
$this->twig->registerUndefinedFunctionCallback(function ($name) {
if (function_exists($name)) {
return new \Twig_Function_Function($name);
return new \Twig_SimpleFunction($name, $name);
}
return new \Twig_Function_Function(function () {
return new \Twig_SimpleFunction($name, function () {
});
});
}
@@ -133,10 +136,10 @@ class Twig
if ($config->get('system.twig.undefined_filters')) {
$this->twig->registerUndefinedFilterCallback(function ($name) {
if (function_exists($name)) {
return new \Twig_Filter_Function($name);
return new \Twig_SimpleFilter($name, $name);
}
return new \Twig_Filter_Function(function () {
return new \Twig_SimpleFilter($name, function () {
});
});
}
@@ -145,7 +148,7 @@ class Twig
// set default date format if set in config
if ($config->get('system.pages.dateformat.long')) {
$this->twig->getExtension('core')->setDateFormat($config->get('system.pages.dateformat.long'));
$this->twig->getExtension('Twig_Extension_Core')->setDateFormat($config->get('system.pages.dateformat.long'));
}
// enable the debug extension if required
if ($config->get('system.twig.debug')) {
@@ -159,7 +162,7 @@ class Twig
$pages = $this->grav['pages'];
// Set some standard variables for twig
$this->twig_vars = $this->twig_vars + [
$this->twig_vars += [
'config' => $config,
'system' => $config->get('system'),
'theme' => $config->get('theme'),