Replace/push the toolbars

@param string $text  The text to parse
@param TemplateInterface $template A template object
@return void
426373
public function filter(&$text, TemplateInterface $template)
    {
        $matches = array();

        if(preg_match_all('#<ktml:toolbar([^>]*)>#siU', $text, $matches))
        {
            foreach($matches[0] as $key => $match)
            {
                $attributes = $this->parseAttributes($matches[1][$key]);

                //Create attributes array
                $config = new ObjectConfig($attributes);
                $config->append(array(
                    'type'  => 'actionbar',
                ));

                if($this->getIdentifier()->type != 'lib')
                {
                    if ($this->getIdentifier()->domain) {
                        $identifier = 'com://'.$this->getIdentifier()->domain.'/'.$this->getIdentifier()->package.'.template.helper.'.$config->type;
                    } else {
                        $identifier = 'com:'.$this->getIdentifier()->package.'.template.helper.'.$config->type;
                    }
                } else {
                    $identifier = 'lib:template.helper.'.$config->type;
                }

                $helper = $this->getObject('template.helper.factory')->createHelper($identifier);

                $html = '';
                if($toolbar = $this->getToolbar($helper->getToolbarType()))
                {
                    $config->toolbar = $toolbar; //set the toolbar in the config
                    
                    $html = $helper->render($config);
                }

                //Remove placeholder
                $text = str_replace($match, $html, $text);
            }
        }
    }
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);
        }
    }
698700
public function manipulate(\DOMDocument $document, LayoutInterface $layout): void
    {
        $host = '//' . $layout->getSource()->getHost();

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('a') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'href', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('link') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'href', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('img') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'src', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('script') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'src', $host);
        }

        $xPath = new \DOMXPath($document);
        /** @var \DOMComment[] $comments */
        $comments = $xPath->query('//comment()');
        foreach ($comments as $comment) {
            $this->replaceCommentWithAbsoluteUri($comment, $host);
        }
    }
595706
protected function _afterRender(TemplateContextInterface $context)
    {
        if(is_string($context->result))
        {
            $content = $context->result;

            foreach($this->__filter_queue as $filter) {
                $filter->filter($content, $this->getMixer());
            }

            $context->result = $content;
        }
    }
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);
        }
    }
1112134
public function filter(&$text, TemplateInterface $template)
    {
        $factory = $this->getObject('template.engine.factory');

        $types = $factory->getFileTypes();
        $types = implode('|', $types);

        $matches = array();
        if(preg_match_all('#<ktml:template:('.$types.')>(.*)<\/ktml:template:('.$types.')>#siU', $text, $matches))
        {
            foreach($matches[0] as $key => $match)
            {
                $data = $template->getData();
                $html = $factory->createEngine($matches[1][$key], array('functions' => $template->getFunctions()))
                    ->render($matches[2][$key], $data);

                $text = str_replace($match, $html, $text);
            }
        }
    }
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);
			}
		}
	}
553545
function blockSet(BlockInterface $block, $templateFile) {
		$this->_blockStack[]= $block;
		$this->_templateFileStack[]= $templateFile;
	}
293941
public function apply(&$templateString) {

		$templateString = preg_replace_callback(
			'~<a(.*?)\s+href=("|\')\$([a-z0-9_]+[a-z0-9_.\/-]*)(.*?)\2(.*?)>~i',
			array($this, 'filterHrefWithPath'),
			$templateString
		);

		$templateString = preg_replace_callback(
			'~<a(.*?)\s+href=("|\')\$\/([a-z0-9_.-]+)(.*?)\2(.*?)>~i',
			array($this, 'filterHref'),
			$templateString
		);

	}
1121363
protected function replacePlaceholdersInTemplate($template, array $replace)
    {
        foreach ($replace as $placeholder => $value) {
            $template = str_replace("__{$placeholder}__", $value, $template);
        }

        return $template;
    }
147988
protected function _setPlaceholderTemplate($template)
    {
        if (!is_null($template)) {
            $template = $this->_normalizeStringable($template);
        }

        $this->placeholderTemplate = $template;
    }
524068
protected function _replaceTags(&$text)
    {
        if (!empty($this->_stripped_tags)) {
            $text = str_replace($this->_stripped_tags[0], $this->_stripped_tags[1], $text);
        }
    }
870614
protected function _addAction(&$text, TemplateInterface $template)
    {
        // All: Add the action if left empty
        if (preg_match_all('#<\s*form[^>]+action=""#si', $text, $matches, PREG_SET_ORDER))
        {
            foreach ($matches as $match)
            {
                $str  = str_replace('action=""', 'action="' . $template->route() . '"', $match[0]);
                $text = str_replace($match[0], $str, $text);
            }
        }

        return $this;
    }
753419
public function setTemplateType(TemplateTypeInterface $templateType)
    {
        $this->templateTypeId = $templateType->getId();

        return parent::setTemplateType($templateType);
    }
583861
public function filter(&$text, TemplateInterface $template)
    {
        //Parse the tags
        $tags = $this->_parseTags($text, $template);

        //Prepend the tags again to the text
        $text = $tags.$text;
    }
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);
        }
    }
1236474
public function parameterize(TemplateInterface $template)
    {
        $params = [];

        foreach ($template->getRequirements() as $key => $requirement) {
            if (!$this->input->hasOption($key) || !$this->input->getOption($key)) {
                list($prompt, $default) = $requirement;

                if ('description' === $key) {
                    $v = $this->style->ask($prompt.' (enter "e" to open editor)', $default);

                    if ('e' === $v) {
                        $editor = $this->getHelperSet()->get('editor');
                        $v = $editor->fromString('');
                    }
                } else {
                    if ('branch' === $key && $this->input->hasOption('base') && $this->input->getOption('base')) {
                        $default = $this->input->getOption('base');
                    }
                    if (1 < count($choices = explode('|', $default))) {
                        $v = $this->style->choice($prompt.' ', $choices, $choices[0]);
                    } else {
                        $v = $this->style->ask($prompt.' ', $default);
                    }
                }
            } else {
                $v = $this->input->getOption($key);
            }

            $params[$key] = $v;
        }

        $template->bind($params);
    }