marcostoll/processwire-template-twig-replace — pull request #5 by justonestep (2014-11-12 17:26:27+00:00)
Title: adding support for prepending and appending files

I wanted to use

```php
$config->prependTemplateFile = '_init.php';
$config->appendTemplateFile = '_done.php';
````

functionality but it does not work. This fix works for me but maybe there is a better way to solve it.

I added some code in **function renderPageWithTwig**

```php
$defaultOptions = array(
+ 'prependFile' => $page->template->noPrependTemplateFile ? null : $config->prependTemplateFile,
+ 'prependFiles' => $page->template->prependFile ? array($page->template->prependFile) : array(),
+ 'appendFile' => $page->template->noAppendTemplateFile ? null : $config->appendTemplateFile,
+ 'appendFiles' => $page->template->appendFile ? array($page->template->appendFile) : array(),
'forceBuildCache' => false,
);
```

```php
+ $files = $this->getPrependAppendFiles($page, $options, $config);
+ $output = $this->combineOutput($files, $page);
```

Please have a look at **getPrependAppendFiles** and **combineOutput** at the end.