- <xslt:template match="html:shrine-header" mode="template">
- <xslt:for-each select="$source/*/@data-shrine-header">
- <xslt:apply-templates select="document(concat('./', ., '-header.xml'), $template)/*" mode="content"/>
- </xslt:for-each>
+ <xslt:template match="html:shrine-header|html:shrine-footer" mode="template">
+ <xslt:param name="context" select="'shrine-template'"/>
+ <xslt:variable name="kind" select="substring-after(local-name(), 'shrine-')"/>
+ <xslt:choose>
+ <xslt:when test="$context='shrine-template'">
+ <xslt:for-each select="$source/*/@*[name()=concat('data-shrine-', $kind)]">
+ <xslt:for-each select="document(concat('./', ., '-', $kind, '.xml'), $template)/*">
+ <xslt:element name="{local-name()}">
+ <xslt:for-each select="@*">
+ <xslt:copy/>
+ </xslt:for-each>
+ <xslt:for-each select="$source//*[@slot=concat('shrine-', $kind, '-before')]">
+ <xslt:apply-templates select="." mode="content"/>
+ </xslt:for-each>
+ <xslt:apply-templates mode="template">
+ <xslt:with-param name="context" select="concat('shrine-', $kind)"/>
+ </xslt:apply-templates>
+ <xslt:for-each select="$source//*[@slot=concat('shrine-', $kind, '-after')]">
+ <xslt:apply-templates select="." mode="content"/>
+ </xslt:for-each>
+ </xslt:element>
+ </xslt:for-each>
+ </xslt:for-each>
+ </xslt:when>
+ <xslt:otherwise>
+ <xslt:element name="{local-name()}">
+ <xslt:for-each select="@*">
+ <xslt:copy/>
+ </xslt:for-each>
+ <xslt:apply-templates mode="template"/>
+ </xslt:element>
+ </xslt:otherwise>
+ </xslt:choose>