mikecao/flight — Issue #3: Passing variables to the layout
Author: christophervalles
Created: 2011-11-26 22:18:02+00:00
State: open

Hi man!

First of all nice work on this framework I love it's simplicity and small footprint.

Right 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.

By 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);`.

If 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.
If this is not the expected behavior I think the patch is really easy (added below just in case).

On line 538 of Flight.php replace:

`self::view()->render($layout, array($key => $content));`

with:

`self::view()->render($layout, array_merge((array)$data, array($key => $content)));`

Thank you!