public function renderViewContents($scopeItems)
    {
        $shouldRender = function() {
            $app = Application::getFacadeApplication();

            // If you hook into this event and use `preventRendering()`,
            // you can prevent the block from being displayed.
            $event = new BlockBeforeRender($this->block);
            $app->make('director')->dispatch('on_block_before_render', $event);

            return $event->proceed();
        };

        if (!$shouldRender()) {
            return;
        }

        unset($shouldRender);

        extract($scopeItems);
        if (!$this->outputContent) {
            ob_start();
            include $this->template;
            $this->outputContent = ob_get_contents();
            ob_end_clean();
        }

        // The translatable texts in the block header/footer need to be printed
        // out in the system language.
        $loc = Localization::getInstance();
        $loc->pushActiveContext(Localization::CONTEXT_UI);

        if ($this->blockViewHeaderFile) {
            include $this->blockViewHeaderFile;
        }

        $this->controller->registerViewAssets($this->outputContent);

        $this->onBeforeGetContents();
        $this->fireOnBlockOutputEvent();
        echo $this->outputContent;
        $this->onAfterGetContents();

        if ($this->blockViewFooterFile) {
            include $this->blockViewFooterFile;
        }

        $loc->popActiveContext();
    }