1
1
<?php
2
2
3
3
/*!
4
- * Mustache Pattern Engine Loader Class - Patterns
4
+ * Twig Pattern Engine Loader Class - Patterns
5
5
*
6
6
* Copyright (c) 2014 Dave Olsen, http://dmolsen.com
7
7
* Licensed under the MIT license
8
8
*
9
- * Sets an instance of Mustache to deal with rendering of patterns
9
+ * Sets an instance of Twig to deal with patterns. Tries to find
10
+ * files on system first. If not tries to load them as strings.
10
11
*
11
12
*/
12
13
13
14
namespace PatternLab \PatternEngine \Twig \Loaders ;
14
15
15
16
use \PatternLab \Config ;
16
- use \PatternLab \PatternEngine \Twig \Loaders \Twig \PatternLoader as Twig_Loader_PatternLoader ;
17
+ use \PatternLab \PatternEngine \Twig \Loaders \Twig \PatternPartialLoader as Twig_Loader_PatternPartialLoader ;
18
+ use \PatternLab \PatternEngine \Twig \Loaders \Twig \PatternStringLoader as Twig_Loader_PatternStringLoader ;
17
19
use \PatternLab \PatternEngine \Loader ;
18
20
19
21
class PatternLoader extends Loader {
@@ -24,9 +26,11 @@ class PatternLoader extends Loader {
24
26
public function __construct ($ options = array ()) {
25
27
26
28
//default var
27
- $ patternSourceDir = Config::getOption ("patternSourceDir " );
28
- $ twigLoader = new Twig_Loader_PatternLoader ($ patternSourceDir ,array ("patternPaths " => $ options ["patternPaths " ]));
29
- $ this ->instance = new \Twig_Environment ($ twigLoader );
29
+ $ patternSourceDir = Config::getOption ("patternSourceDir " );
30
+ $ patternPartialLoader = new Twig_Loader_PatternPartialLoader ($ patternSourceDir ,array ("patternPaths " => $ options ["patternPaths " ]));
31
+ $ patternStringLoader = new \Twig_Loader_String ();
32
+ $ twigLoader = new \Twig_Loader_Chain (array ($ patternPartialLoader , $ patternStringLoader ));
33
+ $ this ->instance = new \Twig_Environment ($ twigLoader );
30
34
31
35
}
32
36
0 commit comments