marcostoll/processwire-template-data-providers — pull request #7 by owzim (2014-12-11 11:28:06+00:00)
Title: automatic page context

Summary:

add feature to have the `$page`, on which renderChunk is called on automatically be assigned to `ChunkDataProvider::page`

Sorry for the unclean diff, I have autostrip trailing whitespace enabled in Sublime Text, you could add only the one relevant line.

Now to the PR:

I have to admit, that I find the context stuff rather unintuitive and not too usable.

This PR makes the following possible:

```PHP
foreach ($sections as $section) {
$section->renderChunk('section.php');
// instead of $page->renderChunk('section.php', $section)
// which would also make it necessary to assign the context
// to a variable of my choosing in the Provider manually,
// see the chunk example in your readme
}
```
Since `renderChunk` is called on `$section`, the section will now automatically assigned to the Providers page var, so in my template `section.php`, I can use the `$page` var, which holds the $section it is called on.

```
$page->title; // it's the section's title
```
This makes the context stuff obsolete for me.

This does not break any of the context stuff.