Skip to content

Instantly share code, notes, and snippets.

@brod-ie brod-ie/Slim.php
Last active Dec 20, 2015

Embed
What would you like to do?
`\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
You can’t perform that action at this time.