Mustache::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix\View\Template;
14
15
use Apix\View\Template,
16
    Apix\View\ViewModel;
17
18
class Mustache extends Template
19
{
20
    public $options = null;
21
22
    /**
23
     * Constructor.
24
     */
25
    public function __construct(array $options = array())
26
    {
27
        $opts = array('extension' => '.ms');
28
        $defaultOptions = array(
29
            'loader'            => new \Mustache_Loader_FilesystemLoader($options['view_dir'], $opts),
30
            'partials_loader'   => new \Mustache_Loader_FilesystemLoader($options['view_dir'] . '/partials', $opts),
31
            'cache'             => '/tmp/cache/mustache'
32
        );
33
34
        $this->options = $defaultOptions + $options;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function render(ViewModel $model)
41
    {
42
        $m = new \Mustache_Engine($this->options);
43
44
        return $m->render($this->layout, $model);
45
    }
46
47
}
48