Locate and retrieve a template in the template path stack

@param  string $template
@return string
@throws Exception\TemplateNotFoundException
543759
private function fetchTemplate($template)
    {
        $resolver = $this->getResolver();
        $content  = $resolver->resolve($template);

        if (! $content) {
            throw new Exception\TemplateNotFoundException('Template by name "' . $template . '" not found');
        }

        return $content;
    }
1050836
protected function getTemplate($template)
    {
        $template = config("imagecache.templates.{$template}");

        switch (true) {
            // closure template found
            case is_callable($template):
                return $template;

            // filter template found
            case class_exists($template):
                return new $template;

            default:
                // template not found
                abort(404);
                break;
        }
    }
804930
public function find($template)
    {
        is_array($template) and $template = array_filter($template, 'is_string');
        if ((! is_string($template) && ! is_array($template)) || empty($template)) {
            throw new InvalidArgumentException(
                'Template name must be a string or an array of strings.'
            );
        }
        if (is_array($template)) {
            return $this->findMany($template);
        }
        $parse = $this->parseName($template);
        if ($parse['dir']) {
            return $this->findInDir($parse['dir'], $parse['file']);
        }

        return $parse['file'] ? $this->scanFor($parse['file']) : false;
    }
926662
protected function templateExists($template)
    {
        try {
            $class = $this->templating->getTemplateClass($template);
        } catch (Twig_Error_Loader $e) {
            return false;
        }

        return $template;
    }
589228
public function getTemplateFile($template) {
		$templateFileClass = $this->_templateFileClass;		

		$dwooTemplateFile = new $templateFileClass($template);
		
		if (!($dwooTemplateFile instanceof Dwoo_ITemplate)) {
			throw new Dwoo_Exception("Custom templateFile class must be a subclass of Dwoo_ITemplate");
		}

		foreach ($this->_templateFileSettings as $method => $value) {
			if (method_exists($dwooTemplateFile, 'set' . $method)) {
				call_user_func(array($dwooTemplateFile, 'set' . $method), $value);
			}
		}
		
		return $dwooTemplateFile;
	}
1292625
protected function getTemplate($template)
    {
        $source = __DIR__.'/../../templates/'.$template;
        return file_exists($source) ? file_get_contents($source) : null;
    }
945157
private static function get_template_path( $template ) {
		$command_root  = Utils\phar_safe_path( dirname( __DIR__ ) );
		$template_path = "{$command_root}/templates/{$template}";

		if ( ! file_exists( $template_path ) ) {
			WP_CLI::error( "Couldn't find {$template}" );
		}

		return $template_path;
	}
978739
public static function load($template)
	{
		$dom = self::loadAsXML($template) ?: self::loadAsXML(self::fixEntities($template));
		if ($dom)
		{
			return $dom;
		}

		// If the template contains an XSL element, abort now. Otherwise, try reparsing it as HTML
		if (strpos($template, '<xsl:') !== false)
		{
			$error = libxml_get_last_error();

			throw new RuntimeException('Invalid XSL: ' . $error->message);
		}

		return self::loadAsHTML($template);
	}
1333489
protected function getTemplate($template, $name)
    {
        $this->template = $this->file->get($template);

        if ($this->needsScaffolding($template))
        {
            return $this->getScaffoldedTemplate($name);
        }

        // Otherwise, just set the file
        // contents to the file name
        return $name . PHP_EOL;
    }
1351301
public function getCompiledFile($template)
	{	
		$tplFile = static::getTemplateFile($template);
		if ($this->options['engine'] === 'php'){
			return $tplFile;
		}
		
		if(file_exists($tplFile)) {
		    if (is_file($template)) {
		        $tplCompiledFile = static::getCompiledPath() . '/_file/' . md5($template) . '.php';
		    } else {
                $tplCompiledFile = static::getCompiledPath() . $this->_getRelativeTemplate($template) . '.php';
		    }
		    
			if (!$this->options['isCompiled'] || !file_exists($tplCompiledFile) || (@filemtime($tplFile) > @filemtime($tplCompiledFile)) ) {
				$tplCompiledPath = dirname($tplCompiledFile);
				if (!file_exists($tplCompiledPath)) {
					Dir::create($tplCompiledPath, 0755);
				}
				
				$content = file_get_contents($tplFile);
				$content = $this->parse($content);
				
				$strlen = file_put_contents($tplCompiledFile, $content);
				chmod ($tplCompiledFile, 0755);
			}
			
			return $tplCompiledFile;
		} else {
			throw new ViewException('template: ' . $tplFile. ' is not exists.');
		}
	}
830559
public function getTemplateFile($template)
    {
        $paths  = $this->config["path"];
        $suffix = $this->config["suffix"];

        foreach ($paths as $path) {
            $file = $path . "/" . $template . $suffix;
            if (is_file($file)) {
                return $file;
            }
        }

        throw new Exception("Could not find template file '$template'.");
    }
777744
private function pathForTemplate(string $template): string
    {
        $pathes = $this->resourceLoader->availableResourceUris('creator/' . $template);
        if (!isset($pathes[0])) {
            throw new \RuntimeException('Could not load template ' . $template);
        }

        return $pathes[0];
    }
169636
protected function findTemplateFile($file)
    {
        //Add missing extension
        $ext = pathinfo($file, PATHINFO_EXTENSION);
        $file = ($ext === '') ? $file . '.'.$this->getExtension() : $file;

        $found = false;
        foreach ($this->locations as $location) {
            if (is_file($location . '/' . $file)) {
                $found = true;
                $file = $location . '/' . $file;
                continue;
            }
        }

        if (!$found) {
            throw new TemplateNotFoundException('This template was not found in any of the registered locations: ' . $file);
        }

        return $file;
    }
397053
private function findTemplate($template)
    {
        $logicalName = (string) $template;

        if (isset($this->cache[$logicalName])) {
            return $this->cache[$logicalName];
        }

        $template = $this->templateNameParser->parse($template);
        $file = $this->templateLocator->locate($template);

        return $this->cache[$logicalName] = $file;
    }
977605
public function template($template = null)
    {
        if (is_null($template)) {
            return $this->template;
        } else {
            $this->template = $template;
        }
    }
838709
public function getDocumentation($template = null)
    {
        if ($template === null) {
            $template = __DIR__.'/../../doc/templates/docclass.xsl';
        }
        if (!is_file($template)) {
            throw new WSException("Could not find the template file: '$template'");
        }
        $xtpl = new IPXSLTemplate($template);
        $documentation = array();
        $documentation['menu'] = array();
        //loop menu items
        $documentation['menu'] = $this->getClasses();

        if ($this->class) {
            if ($this->class->isUserDefined()) {
                $this->class->properties = $this->class->getProperties(false, false);
                $this->class->methods = $this->class->getMethods(false, false);
                foreach ((array) $this->class->methods as $method) {
                    $method->params = $method->getParameters();
                }
            } else {
                $documentation['fault'] = 'Native class';
            }
            $documentation['class'] = $this->class;
        }
        echo $xtpl->execute($documentation);
    }
11259
public function fetchTemplate(Request $request, $template)
    {
        if (!$this->view instanceof Twig) {
            throw new Exception("Twig provider not registered.");
        }

        foreach ($this->settings['view']['global'] as $key => $map) {
            $key = is_numeric($key) ? $map : $key;

            switch ($key) {
                case 'request':
                    $value = $request;
                    break;

                default:
                    $value = isset($this->container[$key]) ? $this->container[$key] : null;
                    break;
            }

            $this->view->getEnvironment()->addGlobal($map, $value);
        }

        $result = $this->view->fetch(
            $template . $this->settings['view']['extension'],
            $this->data->all()
        );

        return $result;
    }