Get the content for a template

@param string $template

@return string
@throws FileSystemException
349883
protected function getTemplate(string $template) : string
    {
        if (isset($this->templates[$template])) {
            return $this->templates[$template];
        }

        $file = $this->basePath . $template;

        if (file_exists($file)) {
            $this->templates[$template] = file_get_contents($file);
        }

        if (!isset($this->templates[$template]) || !$this->templates[$template]) {
            unset($this->templates[$template]);
            throw new FileSystemException("Template $template not found");
        }

        return $this->templates[$template];
    }
1270742
public function getImage($template, $filename)
    {
        $template = $this->getTemplate($template);
        $path = $this->getImagePath($filename);

        // image manipulation based on callback
        $manager = new ImageManager(Config::get('image'));
        $content = $manager->cache(function ($image) use ($template, $path) {

            if ($template instanceof Closure) {
                // build from closure callback template
                $template($image->make($path));
            } else {
                // build from filter template
                $image->make($path)->filter($template);
            }

        }, config('imagecache.lifetime'));

        return $this->buildResponse($content);
    }
63677
protected function getTemplate($template, $className)
    {
        $this->template = $this->file->get($template);
        $resource = strtolower(Pluralizer::plural(
            str_ireplace('Controller', '', $className)
        ));

        if ($this->needsScaffolding($template))
        {
            $this->template = $this->getScaffoldedController($template, $className);
        }

        $template = str_replace('{{className}}', $className, $this->template);

        return str_replace('{{collection}}', $resource, $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);
    }
502877
protected function resolveTemplate($template)
    {
        if (!$this->pathCache[$template]) {

            foreach (array_reverse($this->templateDirs) as $dir) {
                $path = $dir . DIRECTORY_SEPARATOR . $template .'.'. $this->getFileExtension();
                if (is_readable($path)) {
                    $this->pathCache[$template] = $path;
                    break;
                }
            }

        }

        return $this->pathCache[$template];
    }
941196
public static function getTemplate($template, $format = 'html5')
	{
		$templates = static::getTemplates($template, $format = 'html5');

		return isset($templates[0]) ? $templates[0] : null;
	}
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;
    }
1129785
protected function _renderTemplate($template) {
		if ($section = $this->_findSection($template)) {
			list($before, $type, $tag_name, $content, $after) = $section;

			$rendered_before = $this->_renderTags($before);

			$rendered_content = '';
			$val = $this->_getVariable($tag_name);
			switch($type) {
				// inverted section
				case '^':
					if (empty($val)) {
						$rendered_content = $this->_renderTemplate($content);
					}
					break;

				// regular section
				case '#':
					// higher order sections
					if ($this->_varIsCallable($val)) {
						$rendered_content = $this->_renderTemplate(call_user_func($val, $content));
					} else if ($this->_varIsIterable($val)) {
						foreach ($val as $local_context) {
							$this->_pushContext($local_context);
							$rendered_content .= $this->_renderTemplate($content);
							$this->_popContext();
						}
					} else if ($val) {
						if (is_array($val) || is_object($val)) {
							$this->_pushContext($val);
							$rendered_content = $this->_renderTemplate($content);
							$this->_popContext();
						} else {
							$rendered_content = $this->_renderTemplate($content);
						}
					}
					break;
			}

			return $rendered_before . $rendered_content . $this->_renderTemplate($after);
		}

		return $this->_renderTags($template);
	}
1023111
public function readCachedContent(Smarty_Internal_Template $_template)
    {
        if (is_file($_template->cached->filepath)) {
            return file_get_contents($_template->cached->filepath);
        }
        return false;
    }
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;
	}
137925
protected function solveTemplatePath($template) {
		foreach(array_reverse($this->templatePathSolvers) as $s) {
			if(($r = $s($this, $template)) && file_exists($r))
				return $r;
		}
	}
106691
private function resolveTemplate($template)
    {
        $template = str_replace(
            getcwd(),
            '',
            $this->viewResolver->resolve($template)
        );
        return $template;
    }
1257139
protected function getOutTemplate($template = 'default') {
		// check for current locale
		if ($this->locale != '') {
			$templatefile = $this->templatespath.'/'.$this->locale.'/'.$this->outtemplateprefix.$template.'.htm';
			
			if (file_exists($templatefile)) {
				return $this->locale.'/'.$this->outtemplateprefix.$template;
			}
		}
		
		// if not found, check for default locale
		if ($this->deflocale != '') {
			$templatefile = $this->templatespath.'/'.$this->deflocale.'/'.$this->outtemplateprefix.$template.'.htm';
			
			if (file_exists($templatefile)) {
				return $this->deflocale.'/'.$this->outtemplateprefix.$template;
			}
		}
		
		// if not found then check in root
		$templatefile = $this->templatespath.'/'.$this->outtemplateprefix.$template.'.htm';
			
		if (file_exists($templatefile)) {
			return $this->outtemplateprefix.$template;
		}
		
		// out template not found
		return null;
	}
1112722
public function read(Smarty_Internal_Template $_template)
    {
        if (!$_template->source->handler->recompiled) {
            return file_get_contents($this->filepath);
        }
        return isset($this->content) ? $this->content : false;
    }
1023734
private function fetchResultForNamespace($template, $namespace)
    {
        foreach ($this->getPath($namespace) as $path) {
            if (! empty($path)) {
                $path .= '/';
            }
            $filename = $path . $template;
            $contents = @file_get_contents($filename);
            if ($contents !== false) {
                $key = $namespace . '::' . $template;
                return new Result($key, $contents, false, $this->isCompiled());
            }
        }
        return null;
    }
164773
public function getResponse($template, $filename)
    {
        switch (strtolower($template)) {
            case 'original':
                return $this->getOriginal($filename);

            case 'download':
                return $this->getDownload($filename);

            default:
                return $this->getImage($template, $filename);
        }
    }
364545
public function retrieveForTemplate(Template $template)
    {
        return $this->toEntityCollection(
            $this->getEntityRepository()
                ->createQueryBuilder('zone')
                    ->select('zone', 'components')
                        ->leftJoin('zone.components', 'components')
                    ->where('zone.template = :template')
                        ->setParameter(':template', $template)
                    ->addOrderBy('components.ranking', 'asc')
                ->getQuery()
                    ->getResult()
        );
    }