File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed
src/PatternLab/PatternEngine/Twig/Loaders Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ class FilesystemLoader extends Loader {
23
23
*/
24
24
public function __construct ($ options = array ()) {
25
25
26
- $ twigLoader = new \Twig_Loader_Filesystem (array ($ options ["templatePath " ],$ options ["partialsPath " ]));
26
+ $ macroPath = Config::getOption ("sourceDir " ).DIRECTORY_SEPARATOR ."_macros " ;
27
+ $ twigLoader = new \Twig_Loader_Filesystem (array ($ options ["templatePath " ],$ options ["partialsPath " ],$ macroPath ));
27
28
$ this ->instance = new \Twig_Environment ($ twigLoader );
28
29
$ this ->instance = TwigUtil::loadMacros ($ this ->instance , "filesystem " );
29
30
Original file line number Diff line number Diff line change @@ -28,9 +28,11 @@ public function __construct($options = array()) {
28
28
29
29
//default var
30
30
$ patternSourceDir = Config::getOption ("patternSourceDir " );
31
+ $ macroPath = Config::getOption ("sourceDir " ).DIRECTORY_SEPARATOR ."_macros " ;
31
32
$ patternPartialLoader = new Twig_Loader_PatternPartialLoader ($ patternSourceDir ,array ("patternPaths " => $ options ["patternPaths " ]));
32
33
$ patternStringLoader = new \Twig_Loader_String ();
33
- $ twigLoader = new \Twig_Loader_Chain (array ($ patternPartialLoader , $ patternStringLoader ));
34
+ $ macroLoader = new \Twig_Loader_Filesystem (array ($ macroPath ));
35
+ $ twigLoader = new \Twig_Loader_Chain (array ($ patternPartialLoader , $ macroLoader , $ patternStringLoader ));
34
36
$ this ->instance = new \Twig_Environment ($ twigLoader );
35
37
$ this ->instance = TwigUtil::loadMacros ($ this ->instance , "pattern " );
36
38
Original file line number Diff line number Diff line change 12
12
13
13
namespace PatternLab \PatternEngine \Twig \Loaders ;
14
14
15
+ use \PatternLab \Config ;
15
16
use \PatternLab \PatternEngine \Loader ;
16
17
use \PatternLab \PatternEngine \Twig \TwigUtil ;
17
18
@@ -22,7 +23,10 @@ class StringLoader extends Loader {
22
23
*/
23
24
public function __construct ($ options = array ()) {
24
25
25
- $ twigLoader = new \Twig_Loader_String ();
26
+ $ macroPath = Config::getOption ("sourceDir " ).DIRECTORY_SEPARATOR ."_macros " ;
27
+ $ macroLoader = new \Twig_Loader_Filesystem (array ($ macroPath ));
28
+ $ stringLoader = new \Twig_Loader_String ();
29
+ $ twigLoader = new \Twig_Loader_Chain (array ($ macroLoader , $ stringLoader ));
26
30
$ this ->instance = new \Twig_Environment ($ twigLoader );
27
31
$ this ->instance = TwigUtil::loadMacros ($ this ->instance , "string " );
28
32
You can’t perform that action at this time.
0 commit comments