[template description]

@param [type] $template [description]

@return [type] [description]
977605
public function template($template = null)
    {
        if (is_null($template)) {
            return $this->template;
        } else {
            $this->template = $template;
        }
    }
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);
    }
746146
protected function compiled($template)
    {
        $template = ltrim($template, '/');
        if (strrchr($template, '.') == $this->extension)
            $template = substr($template, 0, -strlen($this->extension));
        $file = $this->dir . DIRECTORY_SEPARATOR . $template . $this->extension;
        if (!is_file($file))
            throw new \RuntimeException("template not found:$file!");

        $modified = filemtime($file);
        $compiled = $this->temp . DIRECTORY_SEPARATOR . $template . ".{$modified}.php";
        if (!$this->debug && is_file($compiled) && filemtime($compiled) >= $modified)
            return $compiled;

        $content = self::compile(file_get_contents($file), $this->left, $this->right);
        self::writeFile($compiled, $content, $this->temp);

        return $compiled;
    }
1333263
public function render($template = '')
    {
        $result = $template;
        if (is_array($template) || is_object($template)) {
            // Recursively go down into an object/array to tokenize.
            foreach ($result as &$val) {
                $val = $this->render($val);
            }
        } elseif (
            is_string($template)
            && strlen($template) >= self::TEMPLATE_MIN_LENGTH
            && false !== strpos($template, self::TOKEN_KEY_START)
            && false !== strpos($template, self::TOKEN_KEY_END)
        ) {
            if (isset($this->renderCache[$template])) {
                // Already tokenized this exact string.
                $result = $this->renderCache[$template];
            } else {
                // A new or non-tokenized string.
                $this->lastTemplate = $template;
                set_error_handler([$this, 'handleMustacheErrors'], E_WARNING | E_NOTICE);
                $result = $this->engine->render($template, $this->context);
                restore_error_handler();
                if (null !== $result && '' !== $result) {
                    // Store the result in cache for faster lookup later.
                    $this->renderCache[$template] = $result;
                }
            }
        }

        return $result;
    }
1196494
public function getTemplateParameters($template) {
        if (count(self::$_config->template->{$template})) {
            $tplConfig = self::$_config->template->{$template}->toArray();
            return $tplConfig;
        }
        throw new Exception('The template "' . $template . '" is not configured.');
    }
61589
private function buildParts($template)
    {
        $template = str_replace([
            '$NAMESPACE$',
            '$MODEL$',
            '$CREATEREQUESTNAME$',
            '$UPDATEREQUESTNAME$',
            '$CLASS$',
            '$COLLECTION$',
            '$RESOURCE$',
            '$INDEXGET$',
            '$RELATIONSHIPS$',
            '$RELATIONSHIP_COMPACT$',
            '$RELATIONSHIP_COMPACT_EDIT$',
            '$RELATIONSHIP_NAMESPACES$',
            '$FILETRAIT$',
            '$FILESAVING$',
            '$ENUM$',
        ], [
            $this->namespace,
            $this->modelName,
            $this->createRequestName,
            $this->updateRequestName,
            $this->className,
            strtolower($this->modelName),
            strtolower($this->modelName),
            $this->indexBuilder(),
            $this->relationshipsBuilder(),
            $this->compactBuilder(),
            $this->compactEditBuilder(),
            $this->relationshipsNamespaces(),
            $this->files > 0 ? 'use App\Http\Controllers\Traits\FileUploadTrait;' : '',
            $this->files > 0 ? '$request = $this->saveFiles($request);' : '',
            $this->enum > 0 ? $this->enum() : '',
        ], $template);

        return $template;
    }
1171284
protected function getPathToTemplates($template = null)
    {
        $template = Helpers::getPathWithSlash($template ?: Config::getDefaultTemplateName());
        $basePath = base_path(Config::getTemplatesPath() . $template);
        $path = Helpers::getPathWithSlash($basePath);

        if (!$this->isFileExists($path)) {
            throw new Exception('Invalid template. Make sure the following path exists: "' . $path . '"');
        }

        return $path;
    }
94810
protected function echos(string $template): string
	{
		// Closure that matches the "empty else" syntax

		$emptyElse = function($matches)
		{
			if(preg_match('/(.*)((\|\|)|(\s+or\s+))(.+)/', $matches) !== 0)
			{
				return preg_replace_callback('/(.*)((\|\|)|(\s+or\s+))(.+)/', function($matches)
				{
					return '(empty(' . trim($matches[1]) . ') ? ' . trim($matches[5]) . ' : ' . trim($matches[1]) . ')';
				}, $matches);
			}

			return $matches;
		};

		// Compiles echo tags

		return preg_replace_callback('/{{\s*(.*?)\s*}}/', function($matches) use ($emptyElse)
		{
			if(preg_match('/raw\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo %s; ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/preserve\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__, false); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/attribute\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeAttribute(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/js\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeJavascript(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/css\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeCSS(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/url\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeURL(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			else
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__); ?>', $emptyElse($matches[1]));
			}
		}, $template);
	}
183875
public function setTemplate($template)
    {
        if(!$template instanceof TemplateInterface)
        {
            if(empty($template) || (is_string($template) && strpos($template, '.') === false) )
            {
                $identifier         = $this->getIdentifier()->toArray();
                $identifier['path'] = array('template');
                $identifier['name'] = $template;

                $identifier = $this->getIdentifier($identifier);
            }
            else $identifier = $this->getIdentifier($template);

            $template = $identifier;
        }

        $this->__template = $template;

        return $this->__template;
    }
934196
public function setTemplate($template)
    {
        $layout = $this->getViewModel();
        $layout->setTemplate((string) $template);

        return $this;
    }
651709
public function template_include( $template ) {

		if ( '.twig' === substr( $template, - 5 ) ) {
			/** @var \Twig_Environment $twig */
			$twig = $this['twig.environment'];

			echo $twig->render( basename( $template ), apply_filters( 'meadow_context', array() ) );

			die();
		}

		return $template;
	}
534198
private function serializeLocalized(Template $template)
    {
        $localized = [];
        $parameters = $this->parametersSerializer->serialize([Options::SERIALIZE_MINIMAL]);
        $locales = isset($parameters['locales']['available']) ? $parameters['locales']['available'] : [];
        $templateLang = $template->getLang();

        foreach ($locales as $locale) {
            if ($locale !== $templateLang) {
                $localizedTemplate = $this->templateRepo->findOneBy([
                    'name' => $template->getName(),
                    'type' => $template->getType(),
                    'lang' => $locale,
                ]);
                $localized[$locale] = $localizedTemplate ? [
                    'id' => $localizedTemplate->getUuid(),
                    'title' => $localizedTemplate->getTitle(),
                    'content' => $localizedTemplate->getContent(),
                    'lang' => $localizedTemplate->getLang(),
                ] : new \stdClass();
            }
        }

        return $localized;
    }
637886
private function getDomainRegex($template)
    {
        if (preg_match('#https?://(.*)#', $template, $matches)) {
            $template = $matches[1];
        }
        $parameters = [];
        if (strpos($template, '<') !== false) {
            $template = preg_replace_callback(
                '/<(?:\w+):?([^>]+)?>/u',
                function ($matches) use (&$parameters) {
                    $key = '#' . count($parameters) . '#';
                    $parameters[$key] = isset($matches[1]) ? $matches[1] : '\w+';
                    return $key;
                },
                $template
            );
        }
        $template = preg_quote($template);
        $template = strtr($template, $parameters);
        return '/^' . $template . '$/u';
    }
1218880
public function template($template = false, $layout = null)
    {
        if ($template === false) {
            return [
                'template' => $this->_template,
                'layout' => $this->_layout,
            ];
        }
        $this->_template = $template;
        if ($layout !== null) {
            $this->_layout = $layout;
        }

        return $this;
    }
522291
private function loadTemplate($template)
    {
        if (!array_key_exists($template, $this->templateCache)) {
            $this->templateCache[$template] = $this->twig->loadTemplate($template);
        }

        return $this->templateCache[$template];
    }
68592
public function parse($template)
	{
		$dom = TemplateLoader::load($template);

		$ir = new DOMDocument;
		$ir->loadXML('<template/>');

		$this->createXPath($dom);
		$this->parseChildren($ir->documentElement, $dom->documentElement);
		$this->normalizer->normalize($ir);

		return $ir;
	}
397520
public static function load($template)
	{
		// alter template so that it works
		$template = get_template_directory() != substr($template, 0, strlen(get_template_directory())) ? $template : substr($template, strlen(get_template_directory()) + 1);
		$template = get_stylesheet_directory() != substr($template, 0, strlen(get_stylesheet_directory())) ? $template : substr($template, strlen(get_stylesheet_directory()) + 1);
		$template = '.php' != substr($template, -4) ? $template : substr($template, 0, -4);
		// $template = 'templates.' == substr($template, 0, 10) ? $template : 'templates.' . $template;

		$mappedTemplate = static::mapTemplate($template);
		$template = locate_template($mappedTemplate);

		return new Loader($template);
	}