diff --git a/Views.md b/Views.md index 25a2620..5a3840d 100644 --- a/Views.md +++ b/Views.md @@ -22,4 +22,79 @@ Note that when specifying the name of the template in the render method, you can By default Flight will look for a `views` directory for template files. You can set an alternate path for your templates by setting the following config: - Flight::set('flight.views.path', '/path/to/views'); \ No newline at end of file + Flight::set('flight.views.path', '/path/to/views'); + +## Layouts + +It is common for websites to have a single layout template file with interchanging content. To render content to be used in a layout, you can pass in an optional parameter to the `render` method. + + Flight::render('header', array('heading' => 'Hello'), 'header_content'); + Flight::render('body', array('message' => 'World'), 'body_content'); + +Your view will then have saved variables called `header_content` and `body_content`. You can then render your layout by doing: + + Flight::render('layout', array('title' => 'Home Page')); + +If the template files looks like this: + +header.php: + +
+ +body.php: + + + +layout.php: + + + +