Latte\Compiler::processHtmlTagEnd PHP 메소드

processHtmlTagEnd() 개인적인 메소드

private processHtmlTagEnd ( latte\Token $token )
$token latte\Token
    private function processHtmlTagEnd(Token $token)
    {
        if (in_array($this->context, [self::CONTEXT_HTML_COMMENT, self::CONTEXT_HTML_BOGUS_COMMENT], TRUE)) {
            $this->output .= $token->text;
            $this->context = self::CONTEXT_HTML_TEXT;
            return;
        }
        $htmlNode = $this->htmlNode;
        $end = '';
        if (!$htmlNode->closing) {
            $htmlNode->empty = strpos($token->text, '/') !== FALSE;
            if (in_array($this->contentType, [self::CONTENT_HTML, self::CONTENT_XHTML], TRUE)) {
                $emptyElement = isset(Helpers::$emptyElements[strtolower($htmlNode->name)]);
                $htmlNode->empty = $htmlNode->empty || $emptyElement;
                if ($htmlNode->empty) {
                    // auto-correct
                    $space = substr(strstr($token->text, '>'), 1);
                    if ($emptyElement) {
                        $token->text = ($this->contentType === self::CONTENT_XHTML ? ' />' : '>') . $space;
                    } else {
                        $token->text = '>';
                        $end = "</{$htmlNode->name}>" . $space;
                    }
                }
            }
        }
        if ($htmlNode->macroAttrs) {
            $html = substr($this->output, $this->tagOffset) . $token->text;
            $this->output = substr($this->output, 0, $this->tagOffset);
            $this->writeAttrsMacro($html);
        } else {
            $this->output .= $token->text . $end;
        }
        if ($htmlNode->empty) {
            $htmlNode->closing = TRUE;
            if ($htmlNode->macroAttrs) {
                $this->writeAttrsMacro($end);
            }
        }
        $this->context = self::CONTEXT_HTML_TEXT;
        if ($htmlNode->closing) {
            $this->htmlNode = $this->htmlNode->parentNode;
        } elseif ((($lower = strtolower($htmlNode->name)) === 'script' || $lower === 'style') && (!isset($htmlNode->attrs['type']) || preg_match('#(java|j|ecma|live)script|json|css#i', $htmlNode->attrs['type']))) {
            $this->context = $lower === 'script' ? self::CONTEXT_HTML_JS : self::CONTEXT_HTML_CSS;
        }
    }