Foundry: Some improvments and documentation for the include element.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2964 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-11-11 13:20:49 +00:00
parent 723f1b93a2
commit 069a9e0928
4 changed files with 68 additions and 3 deletions

View File

@ -88,8 +88,57 @@
</div>
</xsl:template>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
This element allows it to include template fragments into a template. The element
has two attributes. The <code>file</code> attribute is mandatory and contains
the path the fragment to include, relative to the <code>template</code> directory.
The <code>internal</code> attribute is optional. If set to <code>true</code> the
fragment is loaded from the internal template directory.
</p>
<p>
For example <code>&lt;include file="fragments/footer.xml"&lt;</code> will include
the file <code>templates/fragments/footer.xml</code>. If the <code>internal</code>
attribute is set to <code>true</code> the file
<code>foundry/templates/fragments/footer.xml</code> would be included.
</p>
<p>
An fragment template file included using this element using this element must
contain a <code>fragment-layout</code> element as root.
</p>
</foundry:doc-desc>
<foundry:doc-attributes>
<foundry:doc-attribute name="file">
<p>
Path of the file to include, relative to the <code>templates</code> directory.
</p>
</foundry:doc-attribute>
<foundry:doc-attribute name="internal">
<p>
If set to <code>true</code> the template fragment file is loaded from the
internal template directory.
</p>
</foundry:doc-attribute>
</foundry:doc-attributes>
</foundry:doc>
<xsl:template match="include">
<xsl:apply-templates select="document(foundry:gen-path(./@file))/fragment-layout"/>
<xsl:variable name="internal" as="xs:boolean">
<xsl:choose>
<xsl:when test="./@internal">
<xsl:value-of select="foundry:boolean(./@internal)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:apply-templates select="document(foundry:gen-path(concat('templates/',
./@file),
$internal))/fragment-layout"/>
</xsl:template>

View File

@ -170,10 +170,18 @@ XSLT 2.0 functions.
<xsl:function name="foundry:gen-path" as="xs:string">
<xsl:param name="path" as="xs:string"/>
<!--<xsl:sequence select="concat($theme-prefix, '/', $path)"/>-->
<xsl:sequence select="foundry:gen-path($path, false())"/>
</xsl:function>
<foundry:doc section="devel" type="function">
<foundry:doc-desc>
<p>
Variant of <code>gen-path</code> with an additional <code>internal</code>
parameter. If set to <code>true</code> the file is loaded from the
<code>foundry</code> directory.
</p>
</foundry:doc-desc>
</foundry:doc>
<xsl:function name="foundry:gen-path" as="xs:string">
<xsl:param name="path" as="xs:string"/>
<xsl:param name="internal" as="xs:boolean"/>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment-layout>
<div>
<a href-static="http://www.libreccm.org">LibreCCM.org</a>
</div>
</fragment-layout>

View File

@ -111,7 +111,9 @@
</notes>
</aside>
<footer>
<include file="templates/fragments/footer.xml"/>
<include file="fragments/footer.xml"/>
<include file="fragments/libreccm.xml" internal="yes"/>
</footer>
</body>
</page-layout>