Last active
December 20, 2015 20:49
-
-
Save brod-ie/6192859 to your computer and use it in GitHub Desktop.
`\Slim\View` class extension for use with the Mustache templating engine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)); | |
}); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello, {{ name }}! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment