Prepare the template by adding grid related classes.

@param Template $template The template.

@return void
171738
public function prepare(Template $template): void
    {
        $formLayout = $this->layoutManager->getDefaultLayout();

        if ($formLayout instanceof HorizontalFormLayout) {
            $template->labelColClass  = $formLayout->getLabelColumnClass();
            $template->colClass       = $formLayout->getColumnClass();
            $template->colOffsetClass = $formLayout->getColumnClass(true);
            $template->rowClass       = $formLayout->getRowClass();
            $template->isHorizontal   = true;
        } else {
            $template->labelColClass  = null;
            $template->colClass       = null;
            $template->colOffsetClass = null;
            $template->rowClass       = null;
            $template->isHorizontal   = false;
        }

        $template->formLayout  = $formLayout;
        $template->buttonClass = $this->getButtonClass();
    }
1090648
public function display(string $template)
    {
        if ($this->context && is_callable([$this->context, 'end'])) {
            $this->context->end($this->fetch($template));
        } else {
            echo $this->fetch($template);
        }
    }
1250130
protected static function initializeColumns(\Template $template)
	{
		$layout = Bootstrap::getLayout();

		switch($layout->cols)
		{
			case '2cll':
				$template->leftClass           = $layout->bootstrap_leftClass;
				$template->mainClass           = $layout->bootstrap_mainClass;

				$template->mainClassAttribute  = sprintf(static::$classAttribute, $layout->bootstrap_mainClass);
				$template->leftClassAttribute  = sprintf(static::$classAttribute, $layout->bootstrap_leftClass);
				break;

			case '2clr':
				$template->rightClass          = $layout->bootstrap_rightClass;
				$template->mainClass           = $layout->bootstrap_mainClass;

				$template->mainClassAttribute  = sprintf(static::$classAttribute, $layout->bootstrap_mainClass);
				$template->rightClassAttribute = sprintf(static::$classAttribute, $layout->bootstrap_rightClass);
				break;

			case '3cl':
				$template->leftClass           = $layout->bootstrap_leftClass;
				$template->rightClass          = $layout->bootstrap_rightClass;
				$template->mainClass           = $layout->bootstrap_mainClass;

				$template->mainClassAttribute  = sprintf(static::$classAttribute, $layout->bootstrap_mainClass);
				$template->rightClassAttribute = sprintf(static::$classAttribute, $layout->bootstrap_rightClass);
				$template->leftClassAttribute  = sprintf(static::$classAttribute, $layout->bootstrap_leftClass);
				break;

			default:
				$template->useGrid = false;
				return;
		}

		$template->useGrid = true;
	}
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;
    }
276422
public function createTemplate(Template &$template)
		{
			$form_data = array(
				'template_name' => $template->getName(),
				'template_subject' => $template->getSubject(),
				'template_body_plain' => $template->getBodyPlain(),
				'template_body_html' => $template->getBodyHtml(),
				'template_body_mobile' => $template->getBodyMobile(),
				'charset' => $template->getCharacterSet(),
				'encoding' => $template->getCharacterEncoding(),
				'folder_id' => $template->getFolderId()
			);
			$data = $this->call('createtemplate', $form_data);

			$template->setTemplateId(trim($data[1]));

			//return $template;
		}
570943
public function onParseTemplate(Template $template): void
    {
        if (!$this->environment->isEnabled()) {
            return;
        }

        $this->initialize();
        if ($this->isAutoMappingDisabled($template->getName())) {
            return;
        }

        $templateName = $this->getMappedTemplateName($template->getName());
        if ($templateName) {
            $template->setName($templateName);
        }
    }
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);
	}
553909
public function onLoadComponentTemplate(Template $template, $fileName)
	{
		if (!$this->activeTheme) {
			return;
		}

		$path = $this->activeTheme->getPath() . 'templates' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $fileName;
		if (file_exists($path)) {
			$template->setFile($path);
		} elseif ($parent = $this->activeTheme->getParent()) {
			$parentTheme = $this->getTheme($parent);
			$path = $parentTheme->getPath() . 'templates' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $fileName;
			if (file_exists($path)) {
				$template->setFile($path);
			}
		}
	}
1001021
private function validateTemplate($type, $template)
    {
        $status = '<info>ok</info>';

        try {
            $this->validateTwigTemplate($template);
        } catch (\Exception $e) {
            $status = sprintf('<error>failed: %s</error>', $e->getMessage());
            $this->errors[] = $e->getMessage();
        }

        $this->output->writeln(
            sprintf(
                '    %s: %s -> %s',
                $type,
                $template,
                $status
            )
        );
    }
851558
public function updateTemplate(TemplateInterface $template)
    {
        $template->setRevision($template->getRevision() + 1);

        $this->dumper->dumpTemplate($template);
    }
811148
public function render($template, array $context = array())
    {
        $template = $this->twig->createTemplate($template);

        return $template->render($context);
    }
885764
public function create($template = false)
    {
        $this->addDefaultGeoFields($template);
        $this->useTemplate($template);

        return parent::create();
    }
647050
public function setTemplates(array $templates) {

        if ($templates !== null && is_array($templates)) {
            $this->_userChangedTemplates = array_merge(array_keys($templates), $this->_userChangedTemplates);
        }

        $this->_setTemplatesWrapper($templates);
    }
481633
public function load($template)
    {
        $template = $this->findFirstExistingTemplate($template);
        if (!isset($this->loadedTemplates[ $template ])) {
            $class = $this->getTemplateClassName($template);

            $this->loadedTemplates[ $template ] = new $class($this);
            if (!$this->loadedTemplates[ $template ] instanceof Template) {
                throw new TemplatingException("The compiled class for {$template} is invalid");
            }
        }

        return $this->loadedTemplates[ $template ];
    }
92576
public function setTemplate(string $template): self
    {
        $projectDir = System::getContainer()->get('huh.utils.container')->getProjectDir();

        $this->template = $projectDir.\DIRECTORY_SEPARATOR.ltrim(preg_replace('#^'.$projectDir.'#', '', $template), \DIRECTORY_SEPARATOR);

        return $this;
    }
1067396
protected function rebuildTagsRegion(&$template)
    {
        foreach ($template as $tag => &$val) {
            if (is_numeric($tag)) {
                continue;
            }

            $a = explode('#', $tag);
            $key = array_shift($a);
            $ref = array_shift($a);

            $this->tags[$key][$ref] = &$val;
            if (is_array($val)) {
                $this->rebuildTagsRegion($val);
            }
        }
    }
1072005
private function templates(array $templates)
    {
        if ($templates) {
            foreach ($templates as $template) {
                if ($template->getManaged()) {
                    yield $template;
                }
            }

            return;
        }

        foreach ($this->templateManager->findAll() as $template) {
            if ($template->getManaged()) {
                yield $template;
            }
        }
    }