/** * Render the template. * * @param string $template The template string * @param LayoutInterface|MailInterface $templateInstance The template instance * @param array $variables The variables of template * * @return string The rendered template * * @throws \Exception */ protected function renderTemplate($template, $templateInstance, array $variables = array()) { if (null !== $template) { if ($templateInstance instanceof TwigTemplateInterface) { $tpl = $this->renderer->loadTemplate($templateInstance->getFile()); if ($tpl instanceof \Twig_Template) { $template = $tpl->renderBlock($template, $variables); $template = '' === $template ? null : $template; } } else { $tpl = $this->renderer->createTemplate($template); $template = $tpl->render($variables); } } return $template; }