laravel/framework — pull request #2844 by bencorlett (2013-12-03 01:36:18+00:00)
Title: Fix a bug introduced in #2710 where values could no longer be injected in views

An accidental side effect of #2710 was that environment sections were flushed before a view was rendered. The issue lies in that, `View::inject()` sets up an environment section before rendering happens. By wiping this out, we're no longer accessing the injected values.

I decided it was appropriate to pass an optional closure into `render()`. If a value was returned, anything other than `null`, that value would be returned as a result, rather than the view's contents. The `$view` instance as well as the rendered `$contents` are given to this closure, allowing for some pretty powerful manipulation.

One implementation I provided was that of #2710, `renderSections()`, which will return the rendered sections of the view as an array, using this callback functionality.

![screen shot 2013-12-03 at 12 34 14 pm](https://f.cloud.github.com/assets/181919/1660367/348c3086-5bbb-11e3-8a9a-b7536738dcaa.png)

Finally, I have added further constraints to a couple of tests (in addition to adding tests for this new functionality) to hopefully ensure that the rendering process does not get broken again in the future.