Tale\Jade\Parser\Node::insertBefore PHP Method

insertBefore() public method

This allows fine control over the node's children The new nodes parent will be set to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->insertBefore([element:c], [element:d]) [element:a] (0)[element:b] (1)[element:d] (2)[element:c]
public insertBefore ( Node $node, Node $newNode )
$node Node the child node of this node's children the new node will be inserted before
$newNode Node the new node that will be inserted before the first node
    public function insertBefore(Node $node, Node $newNode)
    {
        $index = $this->indexOf($node);
        if ($index === false) {
            return $this->prepend($newNode);
        }
        array_splice($this->children, $index, 0, [$newNode]);
        $newNode->parent = $this;
        return $this;
    }