diff --git a/docs/simplesamlphp-theming.md b/docs/simplesamlphp-theming.md
index 041b29f1e7ed5e74e88338f9903843c0c0404462..89ea7a572b9ebb1bde08b52876562898ca44913a 100644
--- a/docs/simplesamlphp-theming.md
+++ b/docs/simplesamlphp-theming.md
@@ -131,6 +131,8 @@ If you need to make more extensive customizations to the base template, you shou
 
 Any references to `$this->data['baseurlpath']` in old-style templates can be replaced with `{{baseurlpath}}` in Twig templates. Likewise, references to `\SimpleSAML\Module::getModuleURL()` can be replaced with `{{baseurlpath}}module.php/mymodule/...`
 
+Within templates each module is defined as a separate namespace matching the module name. This allows one template to reference templates from other modules using Twig's `@namespace_name/template_path` notation. For instance, a template in `mymodule` can include the widget template from the `yourmodule` module using the notation `@yourmodule/widget.twig`. A special namespace, `__parent__`, exists to allow theme developers to more easily extend a module's stock template.
+
 Even more advanced changes can be made by defining a theme controller in `config.php`:
 
     'theme.controller' => '\SimpleSAML\Module\mymodule\FancyThemeController',
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index 75bd715823f17dadc3ba7dfdd18fa15a80ae917f..2baeecdfbd1ebe5c53cd78e8d06873f8ba48b232 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -244,6 +244,7 @@ class Template extends Response
                 $templateDirs[] = [
                     $this->theme['module'] => TemplateLoader::getModuleTemplateDir($this->theme['module'])
                 ];
+                $templateDirs[] = ['__parent__' => TemplateLoader::getModuleTemplateDir($this->module)];
             } catch (\InvalidArgumentException $e) {
                 // either the module is not enabled or it has no "templates" directory, ignore
             }
@@ -524,7 +525,7 @@ class Template extends Response
     public function show()
     {
         if ($this->useNewUI) {
-            echo $this->getContents();            
+            echo $this->getContents();
         } else {
             require($this->findTemplatePath($this->template));
         }