Skip to content

Commit 1445d0a

Browse files
committed
adding macro support to loaders
1 parent 84a359b commit 1445d0a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/PatternLab/PatternEngine/Twig/Loaders/FilesystemLoader.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
namespace PatternLab\PatternEngine\Twig\Loaders;
1414

15+
use \PatternLab\Config;
1516
use \PatternLab\PatternEngine\Loader;
17+
use \PatternLab\PatternEngine\Twig\TwigUtil;
1618

1719
class FilesystemLoader extends Loader {
1820

@@ -23,6 +25,7 @@ public function __construct($options = array()) {
2325

2426
$twigLoader = new \Twig_Loader_Filesystem(array($options["templatePath"],$options["partialsPath"]));
2527
$this->instance = new \Twig_Environment($twigLoader);
28+
$this->instance = TwigUtil::loadMacros($this->instance, "filesystem");
2629

2730
}
2831

@@ -34,7 +37,7 @@ public function __construct($options = array()) {
3437
*/
3538
public function render($options = array()) {
3639

37-
return $this->instance->render($options["template"].".twig", $options["data"]);
40+
return $this->instance->render($options["template"].".".Config::getOption("patternExtension"), $options["data"]);
3841

3942
}
4043

src/PatternLab/PatternEngine/Twig/Loaders/PatternLoader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use \PatternLab\PatternEngine\Twig\Loaders\Twig\PatternPartialLoader as Twig_Loader_PatternPartialLoader;
1818
use \PatternLab\PatternEngine\Twig\Loaders\Twig\PatternStringLoader as Twig_Loader_PatternStringLoader;
1919
use \PatternLab\PatternEngine\Loader;
20+
use \PatternLab\PatternEngine\Twig\TwigUtil;
2021

2122
class PatternLoader extends Loader {
2223

@@ -31,6 +32,7 @@ public function __construct($options = array()) {
3132
$patternStringLoader = new \Twig_Loader_String();
3233
$twigLoader = new \Twig_Loader_Chain(array($patternPartialLoader, $patternStringLoader));
3334
$this->instance = new \Twig_Environment($twigLoader);
35+
$this->instance = TwigUtil::loadMacros($this->instance, "pattern");
3436

3537
}
3638

src/PatternLab/PatternEngine/Twig/Loaders/StringLoader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace PatternLab\PatternEngine\Twig\Loaders;
1414

1515
use \PatternLab\PatternEngine\Loader;
16+
use \PatternLab\PatternEngine\Twig\TwigUtil;
1617

1718
class StringLoader extends Loader {
1819

@@ -23,6 +24,7 @@ public function __construct($options = array()) {
2324

2425
$twigLoader = new \Twig_Loader_String();
2526
$this->instance = new \Twig_Environment($twigLoader);
27+
$this->instance = TwigUtil::loadMacros($this->instance, "string");
2628

2729
}
2830

0 commit comments

Comments
 (0)