private function injectRenderer(array $config, Mustache $mustache, ContainerInterface $container)
    {
        if (isset($config['renderer'])) {
            if (is_string($config['renderer']) && $container->has($config['renderer'])) {
                // Assume fully configured at this point.
                $mustache->setRenderer($container->get($config['renderer']));
                return;
            }

            if ($config['renderer'] instanceof Renderer) {
                $mustache->setRenderer($config['renderer']);
            }

            if (is_string($config['renderer']) && class_exists($config['renderer'])) {
                $mustache->setRenderer(new $config['renderer']());
            }
        }

        if (! isset($config['escaper'])) {
            return;
        }

        if ($config['escaper'] instanceof Escaper) {
            $mustache->getRenderer()->setEscaper($config['escaper']);
            return;
        }

        if (! is_string($config['escaper'])) {
            return;
        }

        if ($container->has($config['escaper'])) {
            $mustache->getRenderer()->setEscaper($container->get($config['escaper']));
            return;
        }

        if (class_exists($config['escaper'])) {
            $mustache->getRenderer()->setEscaper(new $config['escaper']());
            return;
        }
    }