Partially renders the section open tokens

@param array $node
@param array $open
@return string
425102
protected function generateOpen(array $node, array &$open): string
    {
        $node['value'] = trim($node['value']);

        //push in the node, we are going to need this to close
        $open[] = $node;

        $argumentList = $this->parseArguments($node['value']);

        //if it's a value
        if (is_null($this->runtime->getHelper($argumentList->getName()))) {
            //run each
            $node['value'] = 'each ' . $node['value'];
            $argumentList = $this->parseArguments($node['value']);
        }

        $helperGen = array($this, "generateNestedHelper");
        $args = array_map(function(Argument $arg) use ($helperGen) {
            if ($arg instanceof HelperArgument) {
                return $helperGen($arg->getArgumentList(), $arg->getValue());
            }
            return $arg->getValue();
        }, $argumentList->getArguments());

        $hash = array();
        foreach ($argumentList->getNamedArguments() as $key => $value) {
            $hash[$key] = sprintf(self::BLOCK_OPTIONS_HASH_KEY_VALUE, $key, $value->getValue());
        }

        $args[] = $this->prettyPrint(self::BLOCK_OPTIONS_OPEN, 0, 2)
            . $this->prettyPrint(sprintf(self::BLOCK_OPTIONS_NAME, $argumentList->getName()))
            . $this->prettyPrint(sprintf(self::BLOCK_OPTIONS_ARGS, str_replace("'", '\\\'', $node['value'])))
            . $this->prettyPrint(sprintf(self::BLOCK_OPTIONS_HASH, implode(', \r\t', $hash)))
            . $this->prettyPrint(self::BLOCK_OPTIONS_FN_OPEN)
            . $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_1)
            . $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_2)
            . $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_3)
            . $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_4);

        return $this->prettyPrint(sprintf(self::BLOCK_ESCAPE_HELPER_OPEN, $argumentList->getName()), -2)
            . $this->prettyPrint('\r\t' . implode(',\r\t', $args), 1, 2);
    }
883352
protected function collapseTokenTree($node)
    {
        $text = '';
        foreach ($node['children'] as $c) {
            if (is_string($c)) {
                $text .= Utils::escapeString($c);
            } else {
                $text .= $this->collapseTokenTree($c);
            }
        }
        $tokenName = $node['token_name'];
        $token = array($node['token_name'], $text, true);

        $token_ = $this->ruleMapperFilter(array($token));
        $token = $token_[0];

        if (isset($this->filters[$tokenName])) {
            foreach ($this->filters[$tokenName] as $filter) {
                $token = call_user_func($filter[1], $token);
            }
        }
        list($tokenName, $text,) = $token;
        return ($tokenName === null) ? $text : Utils::tagBlock($tokenName, $text);
    }
1307657
protected static function _tagPattern( $open = true, $selfClose = false )
    {
        if ( true === $open )
        {
            return static::_openStartDelimiter( $selfClose ) . self::ValuePlaceholder . static::_openEndDelimiter( $selfClose );
        }

        return static::_closeStartDelimiter() . self::ValuePlaceholder . static::_closeEndDelimiter();
    }
1132013
public static function buildTagStampForNode2($node)
    {

        $cleanNode = self::cleanNodeFromAttributes($node);  //! not working

        $newdoc = new DOMDocument();

        $cloned = $cleanNode->cloneNode(TRUE);
        if (!$cloned)
        {
            return;
        }
        $newdoc->appendChild($newdoc->importNode($cloned, TRUE));
        $html = $newdoc->saveXML();
        preg_match_all('#<([a-zA-Z0-9]+)#i', $html, $matches);

        $tagsArr = $matches[1];
        $tagsToRemove = array('script', 'style', 'head', 'link', 'meta', 'sup', 'sub', 'br');
        $tagsArr = array_diff($tagsArr, $tagsToRemove);

        $tagStamp = join('|', $tagsArr);
        $htmlTagsOptimizer = array(
            '.div,', '.table,', '.td,', '.tr,', '.th,', '.a,', '.span,', '.b,', '.i,', '.noindex,', '.img,', '.h1,', '.h2,', '.h3,', '.h4,', '.h5,'
        );
        $tagStamp = trim(str_replace($htmlTagsOptimizer, array_keys($htmlTagsOptimizer), $tagStamp));

        return $tagStamp;
    }
1173404
protected function build($node) {
		return preg_replace_callback(
			'/\{~(.+?)~\}|\{\*(.+?)\*\}|\{\-(.+?)\-\}|'.
			'\{\{(.+?)\}\}((\r?\n)*)/s',
			function($expr) {
				if ($expr[1])
					$str='<?php '.$this->token($expr[1]).' ?>';
				elseif ($expr[2])
					return '';
				elseif ($expr[3])
					$str=$expr[3];
				else {
					$str='<?= ('.trim($this->token($expr[4])).')'.
						($this->interpolation?
							(!empty($expr[6])?'."'.$expr[6].'"':''):'').' ?>';
					if (isset($expr[5]))
						$str.=$expr[5];
				}
				return $str;
			},
			$node
		);
	}
19433
protected function generateClose(array $node, array &$open)
    {
        $node['value'] = trim($node['value']);

        if ($this->findSection($open, $node['value']) === false) {
            throw HandlebarsException::forUnknownEnd($node['value'], $node['line']);
        }

        $buffer = '';

        $i = $this->findSection($open);

        if (!isset($open[$i]['else'])) {
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_5, -1);
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_6);
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_BODY_7);
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_FN_CLOSE);
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_EMPTY);
        } else {
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_BODY_5);
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_BODY_6);
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_BODY_7);
            $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_INVERSE_CLOSE, -1);
        }

        unset($open[$i]);

        $buffer .= $this->prettyPrint(self::BLOCK_OPTIONS_CLOSE, -1);
        $buffer .= $this->prettyPrint(self::BLOCK_ESCAPE_HELPER_CLOSE, -1);

        return $buffer;
    }
558236
protected function getOpenAndClosingPhpTokens($contents)
    {
        return collect(token_get_all($contents))
            ->pluck($tokenNumber = 0)
            ->filter(function ($token) {
                return in_array($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG]);
            });
    }
498232
public function _body($node) {
		$params = '';
		if (isset($node['@attrib'])) {
			$params = $this->resolveAttr($node['@attrib']);
			unset($node['@attrib']);
		}
		$content = array();
		// bypass inner content nodes
		foreach ($node as $el)
			$content[] = $this->template->build($el);
		return '<body'.$params.'>'.implode("\n", $content)."\n".
			$this->render('footer')."\n".'</body>';
	}
1267932
protected function _include(array $node) {
        $attrib=$node['@attrib'];
        $hive='get_defined_vars()';
        $if = false;
        $include = $attrib[0];
        if (isset($attrib[1]) && strpos($attrib[0], 'if ')) {
            $if = substr($attrib[0], 3);
            $include = $attrib[1];
        }

        return
            '<?php '.($if?
                ('if ('.$this->token($if).') '):'').
                ('echo $this->render('.
                    (preg_match('/@.*$/',$include)?
                        $this->token($include):
                        Base::instance()->stringify($include)).','.
                    '$this->mime,'.$hive.'); ?>');
    }
1264080
protected function compileFor(Node $node)
    {

        $subject = $node->subject;
        $phtml = $this->createCode("for ({$subject}) {").$this->newLine();
        $phtml .= $this->compileChildren($node->children).$this->newLine();
        $phtml .= $this->indent().$this->createCode('}').$this->newLine();

        return $phtml;
    }
538996
public function enterNode(Node $node)
    {
        if ($node instanceof ConstFetch || $node instanceof FuncCall) {
            $node->name = null;
        }

        if ($node instanceof FullyQualified) {
            $this->names[] = $node->toString();
        }

        return $node;
    }
868487
protected function renderNodeName($node)
    {
        $encodeName = isset($node['encode']) ? $node['encode'] : $this->encodeNodeNames;
        $name = $encodeName ? Html::encode($node['name']) : $node['name'];

        $template = ArrayHelper::getValue($node, 'template', $this->nodeNameTemplate);
        return strtr($template, [
            '{name}' => $name,
        ]);
    }
72602
protected function &getNode(&$node, $key)
    {
        if (is_array($node) && isset($node[$key])) {
            return $node[$key];
        }

        if (!is_object($node) || !isset($node->$key)) {
            $result = null;
            return $result;
        }

        // Special check for __isset and __get
        if (property_exists($node, $key)) {
            return $node->$key;
        }

        if (method_exists($node, '__get')) {
            $value = $node->__get($key);
            return $value;
        }

        $result = null;
        return $result;
    }
1189555
public function render_node(node $node) {
        $return = '';
        if (is_object($node->url)) {
            $header = \html_writer::link($node->url, $node->title);
        } else {
            $header = $node->title;
        }
        $icon = $node->icon;
        if (!empty($icon)) {
            $header .= $this->render($icon);
        }
        $content = $node->content;
        $classes = $node->classes;
        if (!empty($content)) {
            if ($header) {
                // There is some content to display below this make this a header.
                $return = \html_writer::tag('dt', $header);
                $return .= \html_writer::tag('dd', $content);

                $return = \html_writer::tag('dl', $return);
            } else {
                $return = \html_writer::span($content);
            }
            if ($classes) {
                $return = \html_writer::tag('li', $return, array('class' => 'contentnode ' . $classes));
            } else {
                $return = \html_writer::tag('li', $return, array('class' => 'contentnode'));
            }
        } else {
            $return = \html_writer::span($header);
            $return = \html_writer::tag('li', $return, array('class' => $classes));
        }

        return $return;
    }
885902
protected function renderNodes($nodes)
    {
        $lines = [];

        if (!empty($nodes)) {

            $nodesOptions = $this->nodesOptions;
            $tag = ArrayHelper::remove($nodesOptions, 'tag', 'ol');
            $lines[] =  Html::beginTag($tag, $nodesOptions);

            foreach ($nodes as $node) {
                if (isset($node['visible']) && !$node['visible']) {
                    continue;
                }
                $lines[] = $this->renderNode($node);
            }

            $lines[] =  Html::endTag($tag); 
        }

        return implode("\n", $lines);
    }
777736
protected static function renderNode($node, $document)
    {
        if (static::isTag($node)) {
            # Strip the leading "#"
            $tagName    = substr(array_shift($node), 1);
            $attributes = array();

            if (sizeof($node) > 2) {
                throw new \UnexpectedValueException(
                    "Tags must not consist of more than three elements"
                );
            }

            foreach ($node as $argv) {
                # Is the argument an associative array of attributes?
                if (is_array($argv) and count(array_filter(array_keys($argv), "is_string")) > 0) {
                    $attributes = $argv;
                } else {
                    $content = $argv;
                }
            }

            $el = $document->createElement($tagName);

            foreach ($attributes as $attr => $value) {
                if (is_array($value)) $value = join(" ", $value);

                $el->setAttribute($attr, (string) $value);
            }

            if (isset($content)) {
                $el->appendChild(static::renderNode($content, $document));
            }
        } else if (is_array($node)) {
            $el = $document->createDocumentFragment();

            foreach ($node as $child) {
                $el->appendChild(static::renderNode($child, $document));
            }
        } else {
            $node = (string) $node;
            if (!empty($node)) $node .= "\n";
            $el = $document->createTextNode($node);
        }

        return $el;
    }
400013
public function markById($id, $open=false, $className=null) {
        if(isset($this->markedNodes[$className.'_'.$id])) {
            $this->markChildren($this->markedNodes[$className.'_'.$id]);
            if($open) {
                $this->markedNodes[$className.'_'.$id]->markOpened();
            }
            
            return true;
        } else {
            return false;
        }
    }