Skip to content

Commit 0cb7636

Browse files
committed
now supports string loader for initial pattern & pattern partial loader for includes
1 parent 259a431 commit 0cb7636

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
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

1314
namespace PatternLab\PatternEngine\Twig\Loaders;
1415

1516
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;
1719
use \PatternLab\PatternEngine\Loader;
1820

1921
class 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

Comments
 (0)