diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index 9df0554f75957ce64d6a16b03610f06cda21ea81..1bfd2e5af29e855b765f27479ac43cfe2d087295 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -540,12 +540,14 @@ class Template extends Response
      * @return string The HTML rendered by this template, as a string.
      * @throws \Exception if the template cannot be found.
      */
-    protected function getContents(): string
+    public function getContents(): string
     {
         $this->twigDefaultContext();
+
         if ($this->controller) {
             $this->controller->display($this->data);
         }
+
         try {
             return $this->twig->render($this->twig_template, $this->data);
         } catch (RuntimeError $e) {