Pico::loadConfig(): Improve Twig config parsing

Thanks @refeaime for reporting this
This commit is contained in:
Daniel Rudolf 2017-07-25 14:43:21 +02:00
parent d3c624777f
commit 13b167e23a
No known key found for this signature in database
GPG key ID: A061F02CD8DE4538

View file

@ -465,7 +465,7 @@ class Pico
'rewrite_url' => null,
'theme' => 'default',
'date_format' => '%D %T',
'twig_config' => array('cache' => false, 'autoescape' => false, 'debug' => false),
'twig_config' => null,
'pages_order_by' => 'alpha',
'pages_order' => 'asc',
'content_dir' => null,
@ -486,6 +486,13 @@ class Pico
$this->config['rewrite_url'] = $this->isUrlRewritingEnabled();
}
$defaultTwigConfig = array('cache' => false, 'autoescape' => false, 'debug' => false);
if (!is_array($this->config['twig_config'])) {
$this->config['twig_config'] = $defaultTwigConfig;
} else {
$this->config['twig_config'] += $defaultTwigConfig;
}
if (empty($this->config['content_dir'])) {
// try to guess the content directory
if (is_dir($this->getRootDir() . 'content')) {