Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/petebrowne/slim-layout-view
A Custom View supporting Layouts for the Slim Framework.
https://github.com/petebrowne/slim-layout-view
Last synced: 13 days ago
JSON representation
A Custom View supporting Layouts for the Slim Framework.
- Host: GitHub
- URL: https://github.com/petebrowne/slim-layout-view
- Owner: petebrowne
- License: mit
- Created: 2012-12-29T21:42:32.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-14T19:20:37.000Z (almost 11 years ago)
- Last Synced: 2024-03-14T15:12:31.197Z (8 months ago)
- Language: PHP
- Size: 120 KB
- Stars: 36
- Watchers: 6
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
slim-layout-view
================A Custom View supporting Layouts for the Slim Framework. slim-layout-view requires Slim 2.0+, which now follows the PSR-2 standard.
Installation
------------Add `"petebrowne/slim-layout-view"` to your `composer.json` file:
``` json
{
"require": {
"slim/slim": "2.*",
"petebrowne/slim-layout-view": "0.3.*"
}
}
```And install using composer:
``` bash
$ php composer.phar install
```Configuration
-------------Configure Slim to use slim-layout-view, and optionally set the layout file to use (defaults to `'layout.php'`):
``` php
$app = new \Slim\Slim(array(
'view' => '\Slim\LayoutView',
'layout' => 'layouts/main.php'
));
```Usage
-----Now create your layout file. The content from the rendered view will be in a variable called `$yield`:
``` html+php
```
Now you can render the view in the usual way:
``` php
$app->get('/', function() use ($app) {
$app->render('index.php');
});
```Rendering with custom layouts or without any layout at all is also supported:
``` php
// Use a different layout for this route:
$app->get('/', function() use ($app) {
$app->render('index.php', array('layout' => 'custom_layout.php'));
});// Skip the layout for this route:
$app->get('/index.xml', function() use ($app) {
$app->render('xml.php', array('layout' => false));
});
```Copyright
---------Copyright (c) 2013 [Peter Browne](http://petebrowne.com). See LICENSE for details.