protected function wrap(\DOMElement $element, $html)
    {
        $wrapper = $element->ownerDocument->createDocumentFragment();
        $wrapper->appendXML($html);

        $result = $wrapper->firstChild;
        $element->parentNode->appendChild($wrapper);

        $xpath = new \DOMXpath($element->ownerDocument);
        $targets = $xpath->query('//inky-content', $wrapper);

        if ($targets->length) {
            $parent = $targets->item(0)->parentNode;
            $parent->removeChild($targets->item(0));
            $parent->appendChild($element);
        }

        return $result;
    }
protected function wrap(\DOMElement $element, $html)
    {
        $wrapper = $element->ownerDocument->createDocumentFragment();
        $wrapper->appendXML($html);

        $result = $wrapper->firstChild;
        $element->parentNode->appendChild($wrapper);

        $xpath = new \DOMXpath($element->ownerDocument);
        $targets = $xpath->query('//inky-content', $wrapper);

        if ($targets->length) {
            $parent = $targets->item(0)->parentNode;
            $parent->removeChild($targets->item(0));
            $parent->appendChild($element);
        }

        return $result;
    }
protected function wrap ( \ DOMElement $ element , $ html ) { $ wrapper = $ element -> ownerDocument -> createDocumentFragment ( ) ; $ wrapper -> appendXML ( $ html ) ; $ result = $ wrapper -> firstChild ; $ element -> parentNode -> appendChild ( $ wrapper ) ; $ xpath = new \ DOMXpath ( $ element -> ownerDocument ) ; $ targets = $ xpath -> query ( '//inky-content' , $ wrapper ) ; if ( $ targets -> length ) { $ parent = $ targets -> item ( 0 ) -> parentNode ; $ parent -> removeChild ( $ targets -> item ( 0 ) ) ; $ parent -> appendChild ( $ element ) ; } return $ result ; }
Wrap a DOM node in a template

@param string $html
Wrap a DOM node in a template