Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Views/Mustache.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class Mustache extends \Slim\View
* @var string The path to the directory containing Mustache.php
*/
public static $mustacheDirectory = null;

/**
* @var string The path to the directory containing Mustache partials
*/
public static $mustachePartialsDirectory = null;

/**
* Renders a template using Mustache.php.
Expand All @@ -60,7 +65,10 @@ public function render($template)
{
require_once self::$mustacheDirectory . '/Autoloader.php';
\Mustache_Autoloader::register(dirname(self::$mustacheDirectory));
$m = new \Mustache_Engine();
$partialsDirectory = (!empty(self::$mustachePartialsDirectory) ? self::$mustachePartialsDirectory : $this->getTemplatesDirectory());
$m = new \Mustache_Engine(array(
'partials_loader' => new \Mustache_Loader_FilesystemLoader($partialsDirectory)
));
$contents = file_get_contents($this->getTemplatesDirectory() . '/' . ltrim($template, '/'));
return $m->render($contents, $this->data);
}
Expand Down