https://github.com/mattmezza/slim-handlebars-view
A view for slim based on handlebars.
https://github.com/mattmezza/slim-handlebars-view
handlebars php slim slim-framework template view
Last synced: about 1 month ago
JSON representation
A view for slim based on handlebars.
- Host: GitHub
- URL: https://github.com/mattmezza/slim-handlebars-view
- Owner: mattmezza
- License: mit
- Created: 2017-03-22T00:26:08.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-03T19:47:56.000Z (about 9 years ago)
- Last Synced: 2025-08-12T18:42:57.183Z (10 months ago)
- Topics: handlebars, php, slim, slim-framework, template, view
- Language: PHP
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: license.md
Awesome Lists containing this project
README
# Slim Framework Handlebars View
[](https://travis-ci.org/mattmezza/slim-handlebars-view)
This is a Slim Framework view helper built on top of the Handlebars templating component. You can use this component to create and render templates in your Slim Framework application. It works with [handlebars.php by xamin project](https://github.com/XaminProject/handlebars.php).
## Install
Via [Composer](https://getcomposer.org/)
```bash
$ composer require mattmezza/slim-handlebars-view
```
Requires Slim Framework 3 and PHP 5.5.0 or newer.
## Usage
```php
// Create Slim app
$app = new \Slim\App();
// Fetch DI Container
$container = $app->getContainer();
// Register Twig View helper
$container['view'] = new \Slim\Views\Handlebars(
'path/to/templates',
'partials',
[
'extension' => 'hbs' // default is html
]);
// Define named route
$app->get('/hello/{name}', function ($request, $response, $args) {
return $this->view->render($response, 'profile', [
'name' => $args['name']
]);
})->setName('profile');
// Run app
$app->run();
```
## Testing
```bash
phpunit
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Credits
- [Matteo Merola](https://github.com/mattmezza)
## License
The MIT License (MIT). Please see [License File](license.md) for more information.