Skip to content

Commit 0129efc

Browse files
committed
Template paths are now configurable
1 parent 7a09b5e commit 0129efc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

libraries/Twig.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
class Twig
1212
{
13+
private $config = [
14+
'paths' => [VIEWPATH],
15+
];
16+
1317
private $functions_asis = [
1418
'base_url', 'site_url'
1519
];
@@ -20,6 +24,11 @@ class Twig
2024
private $twig;
2125
private $loader;
2226

27+
public function __construct($params = [])
28+
{
29+
$this->config = array_merge($this->config, $params);
30+
}
31+
2332
public function createTwig()
2433
{
2534
if (ENVIRONMENT === 'production')
@@ -31,8 +40,9 @@ public function createTwig()
3140
$debug = TRUE;
3241
}
3342

34-
if ($this->loader === null) {
35-
$this->loader = new \Twig_Loader_Filesystem([VIEWPATH]);
43+
if ($this->loader === null)
44+
{
45+
$this->loader = new \Twig_Loader_Filesystem($this->config['paths']);
3646
}
3747

3848
$twig = new \Twig_Environment($this->loader, [

0 commit comments

Comments
 (0)