{"issue":{"created_at":"2011-11-26T22:18:02Z","state":"open","updated_at":"2011-12-01T23:46:36Z","comments":1,"user":{"gravatar_id":"8768e85369236e2c898c8d51d36bd440","id":196018,"url":"https://api.github.com/users/christophervalles","avatar_url":"https://secure.gravatar.com/avatar/8768e85369236e2c898c8d51d36bd440?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"christophervalles"},"body":"Hi man!\r\n\r\nFirst of all nice work on this framework I love it's simplicity and small footprint.\r\n\r\nRight now I'm working on an small utility and I'm using layouts, I notice that there is not an easy way to pass data to that layout (for example the title of the page) cause when your are fetching the layout on the _render method of the Flight class the data is hardcoded using `array($key => $content)` as data parameter.\r\n\r\nBy the way I found that at the end the View class does a merge when rendering with the data you have passed and the data assigned directly to the view using `Flight::view()->set('var', $value);`.\r\n\r\nIf this is the expected way to pass data to the layout I think will be great to add a small paragraph on the view section of the webpage (on the learn section) just to let the users know how to do it and avoid them spending time searching how to deal with that. \r\nIf this is not the expected behavior I think the patch is really easy (added below just in case).\r\n\r\nOn line 538 of Flight.php replace:\r\n\r\n`self::view()->render($layout, array($key => $content));`\r\n\r\nwith:\r\n\r\n`self::view()->render($layout, array_merge((array)$data, array($key => $content)));`\r\n\r\nThank you!","assignee":{"gravatar_id":"c0c58556d1d9829c20db66775d4eb341","id":477975,"url":"https://api.github.com/users/mikecao","avatar_url":"https://secure.gravatar.com/avatar/c0c58556d1d9829c20db66775d4eb341?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mikecao"},"labels":[],"id":2357305,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":3,"title":"Passing variables to the layout","closed_at":null,"html_url":"https://github.com/mikecao/flight/issues/3","url":"https://api.github.com/repos/mikecao/flight/issues/3","milestone":null},"action":"created","comment":{"created_at":"2011-12-01T23:46:36Z","updated_at":"2011-12-01T23:46:36Z","user":{"gravatar_id":"c0c58556d1d9829c20db66775d4eb341","id":477975,"url":"https://api.github.com/users/mikecao","avatar_url":"https://secure.gravatar.com/avatar/c0c58556d1d9829c20db66775d4eb341?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mikecao"},"body":"I think I'm going to revert back to the old render method, which was to save the content into a template variable, then render the layout later instead of having it mashed up into one method. So you would do this instead.\r\n\r\n    Flight::render('header', array('message' => 'hello'), 'header_content');\r\n    Flight::render('body', array('text' => 'world'), 'body_content');\r\n    Flight::render('layout', array('title' => 'My Page'));\r\n\r\nThen your layout template would simply be\r\n\r\n    <html>\r\n    <head><?php echo $title; ?></head>\r\n    <body>\r\n    <h1><?php echo $header_content; ?></h1>\r\n    <div><?php echo $body_content; ?></div>\r\n    </body>\r\n    </html>\r\n\r\nAnd yes I do need to provide better examples in the documentation. Thanks for your comments.","id":2984059,"url":"https://api.github.com/repos/mikecao/flight/issues/comments/2984059"}}