diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php
index 9fce99741424bb5778db0e47c5494416043626b4..eab59467a9a40b66703d00e9d4b7589e5c4bd78c 100644
--- a/lib/SimpleSAML/IdP.php
+++ b/lib/SimpleSAML/IdP.php
@@ -169,7 +169,7 @@ class IdP
 
     /**
      * Get SP name.
-     * Only usefd in IFrameLogout it seems.
+     * Only used in IFrameLogout it seems.
      * TODO: probably replace with template Template::getEntityDisplayName()
      *
      * @param string $assocId The association identifier.
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index 5921db0597d4e66d367e0fee3d22aae5ffcd48d9..24ee27082e132ce91967d193dd68a7e58ecf74d6 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -325,6 +325,13 @@ class Template extends Response
                 ['needs_context' => true]
             )
         );
+        // add a filter for preferred entity name
+        $twig->addFilter(
+            new TwigFilter(
+                'entityDisplayName',
+                [$this, 'getEntityDisplayName'],
+            )
+        );
 
         // add an asset() function
         $twig->addFunction(new TwigFunction('asset', [$this, 'asset']));