Helper function for loading a Mustache file by name.

@throws Mustache_Exception_UnknownTemplateException If a template file is not found

@param string $name

@return string Mustache Template source
770967
protected function loadFile($name)
    {
        $fileName = $this->getFileName($name);

        if ($this->shouldCheckPath() && !file_exists($fileName)) {
            throw new Mustache_Exception_UnknownTemplateException($name);
        }

        return file_get_contents($fileName);
    }
921293
public Template getTemplate(final String name) throws ResourceNotFoundException {
        final Template template = this.cachedTemplates.get(name);
        if (template != null) {
            return template;
        }
        return createTemplateIfAbsent(name);
    }
999585
public function loadTemplate($name)
    {
        $template = new Template();
        $template->app = $this;

        if (in_array($name[0], ['.', '/', '\\']) || strpos($name, ':\\') !== false) {
            return $template->load($name);
        } else {
            $dir = is_array($this->template_dir) ? $this->template_dir : [$this->template_dir];
            foreach ($dir as $td) {
                if ($t = $template->tryLoad($td.'/'.$name)) {
                    return $t;
                }
            }
        }

        throw new Exception(['Can not find template file', 'name'=>$name, 'template_dir'=>$this->template_dir]);
    }
346411
private function getTemplateFile($name)
    {
        return Request::get('system.root').$this->config['path'].(isset($this->config['module']) ? $this->config['module'] : '').'/'.$name.$this->config['suffix'];
    }
325658
protected function load($name)
    {
        $template = $this->parser->parse($name);

        $key = $template->getLogicalName();
        if (isset($this->cache[$key])) {
            return $this->cache[$key];
        }

        $storage = $this->loader->load($template);

        if (false === $storage) {
            throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', $template));
        }

        return $this->cache[$key] = $storage;
    }
1051048
public function findTemplate($name)
    {
        if ($this->files->exists($name)) {
            return $name;
        }

        $name = $this->normalizeName($name);

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

        try {
            $this->cache[$name] = $this->finder->find($name);
        } catch (InvalidArgumentException $ex) {
            throw new LoaderError($ex->getMessage());
        }

        return $this->cache[$name];
    }
787356
public function load($filename)
    {
        if ($t = $this->tryLoad($filename)) {
            return $t;
        }

        throw new Exception([
            'Unable to read template from file',
            'cwd'  => getcwd(),
            'file' => $filename,
        ]);
    }
1144690
public function getFinalName($name){

        try { 

            return parent::findTemplate($name);

        } catch(\Twig_Error_Loader $e){ 

            $exts = \App::config('TEMPLATE_EXTENSION');

            if($exts){

                if(!is_array($exts)){
                    $exts = Array($exts);
                }//if

                foreach($exts as $e){

                    try {
                        return parent::findTemplate($name . $e);
                    } catch(\Twig_Error_Loader $e){ }

                }//foreach

            }//if

        }//catch

        throw new \Twig_Error_Loader("Twig Error Loader Exception : Could name find template `{$name}`");

    }
1143185
public function getLoadedPlugin($name)
    {
        if (!isset($this->loadedPlugins[$name]) || is_null($this->loadedPlugins[$name])) {
            throw new \Exception("The plugin '$name' has not been loaded.");
        }
        return $this->loadedPlugins[$name];
    }
1225089
function getSource($name)
    {
        if (isset($this->site->pages[$name])) {
            $content = $this->site->pages[$name];
        }
        else {
            throw new \Exception("Cannot find content \"$name\".");
        }

        if (!$content->template) {
            throw new \Exception("Content does not have a template");
        }

        if ($content->template !== 'none') {
            $block = 'content';

            // Custom Block?
            if (strpos($content->template, '::') !== false) {
                list($content->template, $block) = explode('::', $content->template);
            }

            // Create template content
            $template = "{% extends \"$content->template\" %}";
            $template .= "{% block $block %}";
            $template .= $content->content;
            $template .= "{% endblock %}";
        }
        else {
            $template = $content->content;
        }

        return $template;
    }
1113763
public function getSingleTemplate(string $name): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/gitignore/templates/:name', $name));
    }
722878
public function load($name)
    {
        $this->loadTemplates();

        if (!array_key_exists($name, $this->templates)) {
            throw new Mustache_Exception_UnknownTemplateException($name);
        }

        return $this->templates[$name];
    }
163778
public function getTemplateFilePath($templateName)
    {
        $templateList = array_merge(
            [ $this ],
            $this->getParentList()
        );

        /** @var TemplateDefinition $templateDefinition */
        foreach ($templateList as $templateDefinition) {
            $templateFilePath = sprintf(
                '%s%s/%s',
                THELIA_TEMPLATE_DIR,
                $templateDefinition->getPath(),
                $templateName
            );

            if (file_exists($templateFilePath)) {
                return $templateFilePath;
            }
        }

        throw new TemplateException("Template file not found: $templateName");
    }
1025983
protected function getTemplate($template, $name)
    {
        // We begin by fetching the master migration stub.
        $stub = $this->file->get(__DIR__.'/templates/migration/migration.txt');

        // Next, set the migration class name
        $stub = str_replace('{{name}}', \Str::studly($name), $stub);

        // Now, we're going to handle the tricky
        // work of creating the Schema
        $upMethod = $this->getUpStub();
        $downMethod = $this->getDownStub();

        // Finally, replace the migration stub with the dynamic up and down methods
        $stub = str_replace('{{up}}', $upMethod, $stub);
        $stub = str_replace('{{down}}', $downMethod, $stub);

        return $stub;
    }
1280300
private function getRawData($name)
    {
        if (isset($this->presets[$name])) {
            return $this->presets[$name];
        }

        // if we use the old flow (sf3), the raw data can be stored in it's own yml file
        if (strpos($name, ':')) {
            $nameParts = explode(':', $name, 2);
            if (2 !== count($nameParts)) {
                throw new \Exception(sprintf('Malformed namespaced configuration name "%s" (expecting "namespace:pagename").', $name));
            }
            list($namespace, $name) = $nameParts;
            $path = $this->kernel->locateResource('@'.$namespace.'/Resources/config/pagetemplates/'.$name.'.yml');
            $rawData = Yaml::parse(file_get_contents($path));

            return $rawData;
        }

        throw new \Exception(sprintf('Non existing template "%s".', $name));
    }
1350285
public function getSource($name)
    {
        /** @var TemplateDocument $doc */
        $doc = $this->getDocument($name);
        if (is_null($doc) || !($doc instanceof TemplateDocument))
        {
            throw new Twig_Error_Loader(sprintf('Template "%s" does not exist.', $name));
        }
        $content = $doc->getContent();
        return $content;
    }
1030870
public function getFile($name)
    {
        if ($file = $this->resolveFile($name)) {
            return $file;
        } else {
            $components = $this->parseResource($name);
            throw new \RuntimeException(sprintf('Template "%s" not found in directories "%s"', $components['file'], implode('", "', $components['dirs'])));
        }
    }