public function compileDocument($input, $path = null)
    {
        $element = $this->compileIntoElement($input, $path);
        $layout = $this->getLayout();
        $blocksCompiler = $this;
        if ($layout) {
            $element = $layout->getDocument();
            $blocksCompiler = $layout->getCompiler();
        }
        $blocksCompiler->compileBlocks();

        return $element;
    }