@param string $template
@param bool   $clearAssignments

@return string
@throws DomainException
660
public function fetch($template, $clearAssignments = true)
    {

        extract($this->variablesForTemplate, EXTR_OVERWRITE);

        $template = $this->templateFolder . $template . '.template.php';

        if (file_exists($template) === false) {
            throw new DomainException('Template not found in ' . $template);
        }

        ob_start();

        /** @noinspection PhpIncludeInspection */
        include $template;

        $content = ob_get_clean();

        if ($clearAssignments) {
            $this->variablesForTemplate = [];
        }

        return $content;
    }
187190
public function load(TemplateReferenceInterface $template)
    {
        $key = hash('sha256', $template->getLogicalName());
        $dir = $this->dir.\DIRECTORY_SEPARATOR.substr($key, 0, 2);
        $file = substr($key, 2).'.tpl';
        $path = $dir.\DIRECTORY_SEPARATOR.$file;

        if (is_file($path)) {
            if (null !== $this->logger) {
                $this->logger->debug('Fetching template from cache.', ['name' => $template->get('name')]);
            }

            return new FileStorage($path);
        }

        if (false === $storage = $this->loader->load($template)) {
            return false;
        }

        $content = $storage->getContent();

        if (!is_dir($dir) && !@mkdir($dir, 0777, true) && !is_dir($dir)) {
            throw new \RuntimeException(sprintf('Cache Loader was not able to create directory "%s"', $dir));
        }

        file_put_contents($path, $content);

        if (null !== $this->logger) {
            $this->logger->debug('Storing template in cache.', ['name' => $template->get('name')]);
        }

        return new FileStorage($path);
    }
270375
public static function getAdminTemplate($template, $module = null)
    {
        $rtn = null;

        $path = static::getPath($template, $module);

        if (!is_null($path)) {
            $templateSrc = file_get_contents($path . $template . '.html');
            $rtn = new static($templateSrc);
            Event::trigger('AdminTemplateLoaded', $rtn);

            if (!is_null($rtn)) {
                $rtn->addFunction('hash', function ($args) {
                    return md5($args['value']);
                });
            }

            return $rtn;
        }

        throw new \Exception('Template does not exist: ' . $template);
    }
132738
public static function getQueryTemplate($template, ...$arguments)
    {
        $strQuery = $template;
        foreach ($arguments as $i => &$argument) {
            $strQuery = str_replace('%' . $i, $argument, $strQuery);
        }

        return $strQuery;
    }
1191887
public function normalizeTemplate($template)
	{
		$dom = TemplateLoader::load($template);

		// Apply all the normalizations until no more change is made or we've reached the maximum
		// number of loops
		$i = 0;
		do
		{
			$old = $template;
			foreach ($this->collection as $k => $normalization)
			{
				$normalization->normalize($dom->documentElement);
			}
			$template = TemplateLoader::save($dom);
		}
		while (++$i < $this->maxIterations && $template !== $old);

		return $template;
	}
635766
protected function recursiveRender($template)
    {
        $output = '';
        foreach ($template as $val) {
            if (is_array($val)) {
                $output .= $this->recursiveRender($val);
            } else {
                $output .= $val;
            }
        }

        return $output;
    }
246997
public function registerTemplate($template)
    {
        $template = $this->normalizeTemplateDuringRegistration($template);

        $this->templates[$template['name']] = $template;

        $this->registerTemplateAliases($template, $template['aliases']);
    }
1254892
public function setTemplate($template)
    {
        if (Format::isUri($template) === true || (gettype($template) === 'string' && empty($template) === true)) {
            $this->template = $template;
        } else {
            $msg = "The given template '${template}' is not a valid URI.";
            throw new InvalidArgumentException($msg);
        }
    }
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];
    }
726192
protected function convertTemplate($template, $passthroughIdx)
	{
		// Replace numeric references in the template with the value of the corresponding attribute
		// values or passthrough
		$template = TemplateModifier::replaceTokens(
			$template,
			$this->referencesRegexp,
			function ($m, $node) use ($passthroughIdx)
			{
				$key = (int) trim($m[0], '\\${}');
				if ($key === 0)
				{
					// $0 copies the whole textContent
					return ['expression', '.'];
				}
				if ($key === $passthroughIdx && $node instanceof DOMText)
				{
					// Passthrough capture, does not include start/end tags
					return ['passthrough'];
				}
				if (isset($this->captures[$key]['name']))
				{
					// Normal capture, replaced by the equivalent expression
					return ['expression', '@' . $this->captures[$key]['name']];
				}

				// Non-existent captures are simply ignored, similarly to preg_replace()
				return ['literal', ''];
			}
		);

		// Unescape backslashes and special characters in the template
		$template = TemplateModifier::replaceTokens(
			$template,
			'(\\\\+[0-9${\\\\])',
			function ($m)
			{
				return ['literal', stripslashes($m[0])];
			}
		);

		return $template;
	}
276190
protected function load($template){
		$template = get_stylesheet_directory()."/templates/admin/{$template}.php";
		/**
		 * wpametu_admin_screen_template
		 *
		 * @param string $template
		 * @param string $class_name
		 * @return string
		 */
		$template = apply_filters('wpametu_admin_screen_template', $template, get_called_class());
		if( file_exists($template) ){
			include $template;
		}
	}
677752
public function set_template($template)
	{
		// make sure the template is a View
		if (is_string($template))
		{
			$this->template = $this->view($template);
		}
		else
		{
			$this->template = $template;
		}

		// return the template view for chaining
		return $this->template;
	}
962811
public static function fillIfKeysExist(array $template, array $source)
    {
        $result = $template;
        foreach ($template as $key => $value) {
            if (array_key_exists($key, $source)) {
                $result[$key] = $source[$key];
            }
        }

        return $result;
    }
617450
public static function create($template = 'Response') {
	    $return = null;

	    switch ($template) {
            case 'Discovery':
                $return = new AlexaResponse(
                    new Response(
                        new Event(
                            new Header(),
                            new Payload()
                        )
                    )
                );
            break;

            case 'StateReport':
                $return = new AlexaResponse(
                    new Response(
                        new Event(
                            new Header(),
                            new Payload(),
                            new Endpoint()
                        ),
	                    new Context()
                    )
                );
            break;

            case 'Response':
                $return = new AlexaResponse(
                    new Response(
                        new Event(
                            new Header(),
                            new Payload(),
                            new Endpoint()
                        ),
	                    new Context()
                    )
                );
            break;

		    case 'Authorization':
			    $return = new AlexaResponse(
				    new Response(
					    new Event(
						    new Header(),
						    new Payload()
					    )
				    )
			    );
		    break;

		    case 'Error':
			    $return = new AlexaResponse(
				    new Response(
					    new Event(
						    new Header(),
						    new Payload()
					    )
				    )
			    );
		    break;

            default:
                throw new InvalidArgumentException('Unsupported AlexaResponse template: ' . $template);
            break;
        }

        return $return;
	}
256102
protected function normalizeTemplateDuringRegistration($template)
    {
        if (empty($template['name'])) {
            throw new InvalidArgumentException('Impossible to register a template without "name"');
        }

        if (empty($template['path'])) {
            throw new InvalidArgumentException('Impossible to register a template without "path"');
        }

        $template['description'] = isset($template['description']) ? $template['description'] : '';
        $template['aliases'] = isset($template['aliases']) ? $template['aliases'] : [];
        $template['is_alias'] = false;

        return $template;
    }
589477
public function createFromTemplate($template)
    {
        $parameter = new GroupParameter();
        $parameter->setName($template->name);
        $parameter->setTemplate($template);
        if ($template->type == GroupParameterType::HASHTABLE && isset($template->entries)) {
            $parameter->setChildren($this->createRequiredFromTemplates($template->entries));
        } elseif ($template->type != GroupParameterType::HASHTABLE && $template->type != GroupParameterType::EDITABLE_HASHTABLE) {
            if ($template->type == GroupParameterType::BOOLEAN) {
                $value = true;
            } else {
                $value = empty($template->values) ? '' : $template->values[0];
            }
            $parameter->addValue($value);
        }
        return $parameter;
    }
106691
private function resolveTemplate($template)
    {
        $template = str_replace(
            getcwd(),
            '',
            $this->viewResolver->resolve($template)
        );
        return $template;
    }