11<?php
22
33/*!
4- * Mustache Pattern Engine Loader Class - Patterns
4+ * Twig Pattern Engine Loader Class - Patterns
55 *
66 * Copyright (c) 2014 Dave Olsen, http://dmolsen.com
77 * Licensed under the MIT license
88 *
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.
1011 *
1112 */
1213
1314namespace PatternLab \PatternEngine \Twig \Loaders ;
1415
1516use \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 ;
1719use \PatternLab \PatternEngine \Loader ;
1820
1921class PatternLoader extends Loader {
@@ -24,9 +26,11 @@ class PatternLoader extends Loader {
2426 public function __construct ($ options = array ()) {
2527
2628 //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 );
3034
3135 }
3236
0 commit comments