The first idea that strikes me is that this templating page is called from a method.
class Viewer
{
public $html;
private $title;
private $content;
public function __construct()
{
$this->html = new \Utilities\HTMLBag();
}
public function loadView($template)
{
ob_start();
include 'path/to/views/'.$template.'.php';
$this->content = ob_get_clean();
}
public function title()
{
return $this->title;
}
}
From this point, the included $template
can access any method of Viewer's class