Created
February 16, 2017 16:16
-
-
Save victorknust/798f8b338724d0d0c9fddda13ecdd37f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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