Exemple #1
0
 /**
  * If it's registered in the IoC, resolve from there... otherwise use default
  */
 if (IoC::registered('twig::loader')) {
     $loader = IoC::resolve('twig::loader');
 } else {
     $loader = new Laravel_Twig_Loader($ext);
 }
 /**
  * Hook into the Laravel view loader
  */
 Laravel\Event::override(Laravel\View::loader, function ($bundle, $view) use($loader, $ext) {
     // Use the custom Laravel Twig loader for Twig views...
     if (starts_with($view, 'twig|')) {
         return $loader->getPath($bundle, substr($view, 5));
     } elseif (starts_with($bundle, 'twig|')) {
         return $loader->getPath(substr($bundle, 5), $view);
     } else {
         return View::file($bundle, $view);
     }
 });
 /**
  * Hook into the Laravel view engine
  */
 Laravel\Event::listen(Laravel\View::engine, function ($view) use($loader, $cache, $ext, $debug, $autoescape) {
     // Only handle views that have the Twig marker
     if (!starts_with($view->view, 'twig|')) {
         return false;
     }
     // Load the Laravel Twig extensions
     require_once 'extensions/HTML.php';
     $twig = new Twig_Environment($loader, compact('cache', 'debug', 'autoescape'));