public function testDecoratingRenderedOutputInAfterRenderEvent()
 {
     $mock = $this->getMockRenderer('foobar');
     $dispatcher = new Emitter();
     $dispatcher->addListener(EventTriggeringRenderer::AFTER_RENDER_EVENT, function ($event) {
         $event->setOutput($event->getOutput() . ' + called from event');
     });
     $renderer = new EventTriggeringRenderer($mock, $dispatcher);
     $text = $renderer->render('some source');
     $this->assertSame('foobar + called from event', $text);
 }
<?php

require_once __DIR__ . '/000-example_functions.php';
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Cspray\Platelets\FileRenderer;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Cspray\Platelets\EventTriggeringRenderer;
use function Cspray\Platelets\Examples\stdout;
$fileRenderer = new FileRenderer(__DIR__ . '/templates');
$dispatcher = new EventDispatcher();
$renderer = new EventTriggeringRenderer($fileRenderer, $dispatcher);
$dispatcher->addListener($renderer::AFTER_RENDER_EVENT, function ($event) {
    $event->setOutput($event->getOutput() . ' + called from event');
});
$output = $renderer->render('simple_template');
stdout($output);
<?php

require_once __DIR__ . '/000-example_functions.php';
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Cspray\Platelets\FileRenderer;
use Cspray\Platelets\EventTriggeringRenderer;
use Cspray\Platelets\TwoStepRenderer;
use Cspray\Platelets\AdhocContext;
use Symfony\Component\EventDispatcher\EventDispatcher;
use function Cspray\Platelets\Examples\stdout;
$fileRenderer = new FileRenderer(__DIR__ . '/templates');
$dispatcher = new EventDispatcher();
$twoStepRenderer = new TwoStepRenderer($fileRenderer, 'second_step_layout');
$renderer = new EventTriggeringRenderer($twoStepRenderer, $dispatcher);
$beforeCalled = 0;
$dispatcher->addListener($renderer::BEFORE_RENDER_EVENT, function () use(&$beforeCalled) {
    $beforeCalled++;
    stdout('The before listener has been called ' . $beforeCalled . ' time(s)');
});
$afterCalled = 0;
$dispatcher->addListener($renderer::AFTER_RENDER_EVENT, function () use(&$afterCalled) {
    $afterCalled++;
    stdout('The after listener has been called ' . $afterCalled . ' time(s)');
});
$output = $renderer->render('first_step_content', new AdhocContext(['dynamic' => 'dynamic']));
stdout($output);