public function preParse($snippet, $allowtwig)
    {
        // Quickly verify that we actually need to parse the snippet!
        if (!$allowtwig || !preg_match('/[{][{%#]/', $snippet)) {
            return $snippet;
        }

        // Don't parse Twig for live editor.
        $request = $this->app['request_stack']->getCurrentRequest();
        if ($request && $request->request->getBoolean('_live-editor-preview')) {
            return $snippet;
        }

        $snippet = html_entity_decode($snippet, ENT_QUOTES, 'UTF-8');

        $template = $this->app['twig']->createTemplate((string) $snippet);

        return twig_include($this->app['twig'], $this->getTemplateContext(), $template, [], true, false, true);
    }