public function renderContainer($container, $type = null, array $data = [])
    {
        if (is_string($container)) {
            if (null === $element = $this->editor->getRepository()->findContainerByName($container)) {
                $this->persist($element = $this->editor->getContainerManager()->create($container, $type, $data));
            }
            $container = $element;
        }

        if ($container instanceof EM\ContainerInterface) {
            $this->tagManager->addTags($container->getEntityTag());

            $container = $this->editor->getViewBuilder()->buildContainer($container);
        }

        if (!$container instanceof View\ContainerView) {
            throw new Exception\InvalidArgumentException(
                'Expected string or instance of ' .
                EM\ContainerInterface::class . ' or ' .
                View\ContainerView::class
            );
        }

        /** @noinspection PhpInternalEntityUsedInspection */
        return $this->getTemplate()->renderBlock('cms_container', [
            'container' => $container,
        ]);
    }