File tree Expand file tree Collapse file tree 5 files changed +33
-12
lines changed Expand file tree Collapse file tree 5 files changed +33
-12
lines changed Original file line number Diff line number Diff line change 6
6
7
7
declare (strict_types=1 );
8
8
9
- namespace Magento \Upward \Template ;
9
+ namespace Magento \Upward \Template \ Mustache ;
10
10
11
- class Mustache implements TemplateInterface
11
+ use Magento \Upward \Template \TemplateInterface ;
12
+
13
+ class Engine implements TemplateInterface
12
14
{
13
15
/**
14
16
* @var \Mustache_Engine
@@ -18,7 +20,7 @@ class Mustache implements TemplateInterface
18
20
public function __construct (string $ basePath )
19
21
{
20
22
$ this ->mustacheEngine = new \Mustache_Engine ([
21
- 'partials_loader ' => new \ Mustache_Loader_FilesystemLoader ($ basePath , ['extension ' => 'mst ' ]),
23
+ 'partials_loader ' => new FileLoader ($ basePath , ['extension ' => 'mst ' ]),
22
24
]);
23
25
}
24
26
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ declare (strict_types=1 );
8
+
9
+ namespace Magento \Upward \Template \Mustache ;
10
+
11
+ class FileLoader extends \Mustache_Loader_FilesystemLoader
12
+ {
13
+ protected function loadFile ($ name )
14
+ {
15
+ return trim (parent ::loadFile ($ name ));
16
+ }
17
+ }
Original file line number Diff line number Diff line change 8
8
9
9
namespace Magento \Upward \Template ;
10
10
11
+ use Magento \Upward \Template \Mustache \Engine as MustacheEngine ;
12
+
11
13
class TemplateFactory
12
14
{
13
15
public const TEMPLATE_MUSTACHE = 'mustache ' ;
@@ -16,7 +18,7 @@ class TemplateFactory
16
18
* @var array map of template to renderer implementations
17
19
*/
18
20
private static $ templateClasses = [
19
- self ::TEMPLATE_MUSTACHE => Mustache ::class,
21
+ self ::TEMPLATE_MUSTACHE => MustacheEngine ::class,
20
22
];
21
23
22
24
/**
Original file line number Diff line number Diff line change 6
6
7
7
declare (strict_types=1 );
8
8
9
- namespace Magento \Upward \Test \Template ;
9
+ namespace Magento \Upward \Test \Template \ Mustache ;
10
10
11
- use Magento \Upward \Template \Mustache ;
11
+ use Magento \Upward \Template \Mustache \ Engine ;
12
12
use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
13
13
use PHPUnit \Framework \TestCase ;
14
14
use function BeBat \Verify \verify ;
15
15
16
- class MustacheTest extends TestCase
16
+ class EngineTest extends TestCase
17
17
{
18
18
use MockeryPHPUnitIntegration;
19
19
20
20
public function testRender (): void
21
21
{
22
- $ mustacheEngine = new Mustache (__DIR__ . '/../_data ' );
22
+ $ mustacheEngine = new Engine (__DIR__ . '/.. /../_data ' );
23
23
verify ($ mustacheEngine ->render ('{{> templates/template}} ' , ['variable ' => 'custom variable ' ]))
24
- ->will ()->contain ('<h1>A Mustache Template with a custom variable</h1> ' );
24
+ ->will ()->sameAs ('<h1>A Mustache Template with a custom variable</h1> ' );
25
25
}
26
26
}
Original file line number Diff line number Diff line change 8
8
9
9
namespace Magento \Upward \Test \Template ;
10
10
11
- use Magento \Upward \Template \Mustache ;
11
+ use Magento \Upward \Template \Mustache \ Engine ;
12
12
use Magento \Upward \Template \TemplateFactory ;
13
13
use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
14
14
use PHPUnit \Framework \TestCase ;
@@ -20,7 +20,7 @@ class TemplateFactoryTest extends TestCase
20
20
21
21
public function testGetWithEngine (): void
22
22
{
23
- verify (TemplateFactory::get (__DIR__ , 'mustache ' ))->is ()->instanceOf (Mustache ::class);
23
+ verify (TemplateFactory::get (__DIR__ , 'mustache ' ))->is ()->instanceOf (Engine ::class);
24
24
}
25
25
26
26
public function testGetWithInvalidEngine (): void
@@ -33,6 +33,6 @@ public function testGetWithInvalidEngine(): void
33
33
34
34
public function testGetWithoutEngine (): void
35
35
{
36
- verify (TemplateFactory::get (__DIR__ , null ))->is ()->instanceOf (Mustache ::class);
36
+ verify (TemplateFactory::get (__DIR__ , null ))->is ()->instanceOf (Engine ::class);
37
37
}
38
38
}
You can’t perform that action at this time.
0 commit comments