Ejemplo n.º 1
0
 public static function findTemplate($name, $dirs = null)
 {
     /*
      * Calculate template_source_loaders the first time the function is executed
      * because putting this logic in the module-level namespace may cause
      * circular import errors. See Django ticket #1292.
      */
     if (DjaLoader::$template_source_loaders === null) {
         $loaders = array();
         foreach (Dja::getSetting('TEMPLATE_LOADERS') as $loader_name) {
             $loader = DjaLoader::findTemplateLoader($loader_name);
             if ($loader !== null) {
                 $loaders[] = $loader;
             }
         }
         DjaLoader::$template_source_loaders = $loaders;
     }
     /** @var $loader Closure */
     foreach (DjaLoader::$template_source_loaders as $loader) {
         try {
             list($source, $display_name) = $loader($name, $dirs);
             return array($source, self::makeOrigin($display_name, $loader, $name, $dirs));
         } catch (TemplateDoesNotExist $e) {
             continue;
         }
     }
     throw new TemplateDoesNotExist($name);
 }
Ejemplo n.º 2
0
 public function loaders()
 {
     // Resolve loaders on demand to avoid circular imports
     if (!$this->_cached_loaders) {
         // Set self._cached_loaders atomically. Otherwise, another thread could see an incomplete list. See #17303.
         $cached_loaders = array();
         foreach ($this->_loaders as $loader) {
             $cached_loaders[] = DjaLoader::findTemplateLoader($loader);
         }
         $this->_cached_loaders = $cached_loaders;
     }
     return $this->_cached_loaders;
 }