Skip to content

Instantly share code, notes, and snippets.

@victorknust
Created February 16, 2017 16:16
Show Gist options
  • Save victorknust/798f8b338724d0d0c9fddda13ecdd37f to your computer and use it in GitHub Desktop.
Save victorknust/798f8b338724d0d0c9fddda13ecdd37f to your computer and use it in GitHub Desktop.
<?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