Skip to content

Instantly share code, notes, and snippets.

@victorknust
Created Feb 16, 2017
Embed
What would you like to do?
<?php
class View
{
public function render( $view, array $data = [] )
{
ob_start() and extract($data, EXTR_SKIP);
try {
include $view . '.tpl.php';
} catch (\Throwable $exception) {
ob_get_clean();
throw $exception;
}
return ob_get_clean();
}
public function insert( $view, array $data = [] ) {
echo $this->render( $view, $data );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment