petebrowne/slim-layout-view
最新稳定版本:0.3.0
Composer 安装命令:
composer require petebrowne/slim-layout-view
包简介
A Custom View supporting Layouts for the Slim Framework.
README 文档
README
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:
{
"require": {
"slim/slim": "2.*",
"petebrowne/slim-layout-view": "0.3.*"
}
}
And install using composer:
$ php composer.phar install
Configuration
Configure Slim to use slim-layout-view, and optionally set the layout file to use (defaults to 'layout.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>
<head></head>
<body>
<?php echo $yield ?>
</body>
</html>
Now you can render the view in the usual way:
$app->get('/', function() use ($app) { $app->render('index.php'); });
Rendering with custom layouts or without any layout at all is also supported:
// 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. See LICENSE for details.
统计信息
- 总下载量: 18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 36
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-12-29