Skip to content

Instantly share code, notes, and snippets.

@brod-ie
Last active December 20, 2015 20:49
Show Gist options
  • Save brod-ie/6192859 to your computer and use it in GitHub Desktop.
Save brod-ie/6192859 to your computer and use it in GitHub Desktop.
`\Slim\View` class extension for use with the Mustache templating engine.
<?php
class Mustache extends \Slim\View
{
public function render($template)
{
$mustache = new \Mustache_Engine(
array(
'loader' => new Mustache_Loader_FilesystemLoader(__DIR__.'/'),
// ...
)
);
return $mustache->render($template, $this->data->all());
}
}
$app = new \Slim\Slim(
array(
'view' => new Mustache()
)
);
$app->get('/hello/:name', function ($name) use ($app) {
$app->render('test.mustache', array('name' => $name));
});
?>
Hello, {{ name }}!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment