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 {
2323 */
2424 public function __construct ($ options = array ()) {
2525
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 ));
2728 $ this ->instance = new \Twig_Environment ($ twigLoader );
2829 $ this ->instance = TwigUtil::loadMacros ($ this ->instance , "filesystem " );
2930
Original file line number Diff line number Diff line change @@ -28,9 +28,11 @@ public function __construct($options = array()) {
2828
2929 //default var
3030 $ patternSourceDir = Config::getOption ("patternSourceDir " );
31+ $ macroPath = Config::getOption ("sourceDir " ).DIRECTORY_SEPARATOR ."_macros " ;
3132 $ patternPartialLoader = new Twig_Loader_PatternPartialLoader ($ patternSourceDir ,array ("patternPaths " => $ options ["patternPaths " ]));
3233 $ 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 ));
3436 $ this ->instance = new \Twig_Environment ($ twigLoader );
3537 $ this ->instance = TwigUtil::loadMacros ($ this ->instance , "pattern " );
3638
Original file line number Diff line number Diff line change 1212
1313namespace PatternLab \PatternEngine \Twig \Loaders ;
1414
15+ use \PatternLab \Config ;
1516use \PatternLab \PatternEngine \Loader ;
1617use \PatternLab \PatternEngine \Twig \TwigUtil ;
1718
@@ -22,7 +23,10 @@ class StringLoader extends Loader {
2223 */
2324 public function __construct ($ options = array ()) {
2425
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 ));
2630 $ this ->instance = new \Twig_Environment ($ twigLoader );
2731 $ this ->instance = TwigUtil::loadMacros ($ this ->instance , "string " );
2832
You can’t perform that action at this time.
0 commit comments