Permalink
Browse files

throw exceptions if twig isn't setup

  • Loading branch information...
1 parent 7ab5d8d commit 9108412db12d6938f75cb3e23351f741f27e6d09 @ryanmark ryanmark committed Mar 29, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 shortcuts.php
View
@@ -10,13 +10,16 @@
use mtv\http\Http500;
use mtv\http\AjaxHttp500;
use mtv\models\wp\PostCollection;
+use Exception;
/**
* Render and display a template
**/
function display_template( $template_name, $context=array() ) {
global $twig;
+ if ( !is_object($twig) ) throw new Exception('Twig template engine not available');
+
$template = $twig->loadTemplate( $template_name );
$template->display( $context );
}
@@ -27,6 +30,8 @@ function display_template( $template_name, $context=array() ) {
function render( $template_name, $context=array() ) {
global $twig;
+ if ( !is_object($twig) ) throw new Exception('Twig template engine not available');
+
$template = $twig->loadTemplate( $template_name );
return $template->render( $context );
}

0 comments on commit 9108412

Please sign in to comment.