Skip to content

Commit aa59602

Browse files
committed
Merge branch 'feature-patternloadersplit' into dev
2 parents ca899ee + 0cb7636 commit aa59602

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
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

src/PatternLab/PatternEngine/Twig/Loaders/Twig/PatternLoader.php renamed to src/PatternLab/PatternEngine/Twig/Loaders/Twig/PatternPartialLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use \PatternLab\PatternEngine\Util;
1717

18-
class PatternLoader implements \Twig_LoaderInterface, \Twig_ExistsLoaderInterface {
18+
class PatternPartialLoader implements \Twig_LoaderInterface, \Twig_ExistsLoaderInterface {
1919

2020
/** Identifier of the main namespace. */
2121
const MAIN_NAMESPACE = '__main__';

0 commit comments

Comments
 (0)