aboutsummaryrefslogtreecommitdiff
path: root/source/99_result/stream.xsl
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-12-09 19:03:28 +0100
committerAdrian Kummerlaender2014-12-09 19:03:28 +0100
commit299dbbb58f9b6c6c85563bba4d1e43ae514a7949 (patch)
tree30a77680fb5d015648c1be639312cfb8f2a9bcfe /source/99_result/stream.xsl
parent1b9a49bacf15c72c093b7e6de79b408c28e5b904 (diff)
downloadblog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.gz
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.bz2
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.lz
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.xz
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.tar.zst
blog.kummerlaender.eu-299dbbb58f9b6c6c85563bba4d1e43ae514a7949.zip
Replaced function-like data resolution with template applications
* e.g. article and tag support data is now fetched through direct _XPath_ template applications ** this required the introduction of a special `resolve` mode to prevent interaction between support and main content resolution ** in most cases arguments had to be wrapped inside helper constants to enable selection of e.g. article support data via the `@handle` attribute using the current elements `@handle` attribute * analogously to the recent changes in _StaticXSLT_ this commit aims to improve the XSLT code style used in generating this static website
Diffstat (limited to 'source/99_result/stream.xsl')
-rw-r--r--source/99_result/stream.xsl28
1 files changed, 11 insertions, 17 deletions
diff --git a/source/99_result/stream.xsl b/source/99_result/stream.xsl
index 5d2218c..d71b094 100644
--- a/source/99_result/stream.xsl
+++ b/source/99_result/stream.xsl
@@ -28,24 +28,20 @@
</xsl:choose>
</xsl:template>
-<xsl:template name="get_article">
- <xsl:param name="handle"/>
-
- <xsl:variable name="article" select="$root/articles/entry[@handle = $handle]"/>
-
+<xsl:template match="articles/entry" mode="resolve">
<h2>
<xsl:text>ยป </xsl:text>
- <a href="/article/{$handle}">
- <xsl:value-of select="$article/title"/>
+ <a href="/article/{@handle}">
+ <xsl:value-of select="title"/>
</a>
</h2>
<p class="info">
<xsl:call-template name="format-date">
- <xsl:with-param name="date" select="$article/date/full"/>
+ <xsl:with-param name="date" select="date/full"/>
<xsl:with-param name="format" select="'M x, Y'"/>
- </xsl:call-template>
+ </xsl:call-template>
<xsl:text> | </xsl:text>
- <xsl:for-each select="$article/tags/tag">
+ <xsl:for-each select="tags/tag">
<a href="/tag/{.}">
<xsl:value-of select="."/>
</a>
@@ -55,7 +51,7 @@
<xsl:value-of select="$root/meta/author"/>
</p>
- <xsl:apply-templates select="$article/content/node()" mode="xhtml"/>
+ <xsl:apply-templates select="content/node()" mode="xhtml"/>
</xsl:template>
<xsl:template match="page/entry">
@@ -80,19 +76,17 @@
</xsl:template>
<xsl:template match="page/entry/article">
+ <xsl:variable name="handle" select="@handle"/>
+
<xsl:choose>
<xsl:when test="position() = last()">
<div class="last article">
- <xsl:call-template name="get_article">
- <xsl:with-param name="handle" select="@handle"/>
- </xsl:call-template>
+ <xsl:apply-templates select="$root/articles/entry[@handle = $handle]" mode="resolve"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="article">
- <xsl:call-template name="get_article">
- <xsl:with-param name="handle" select="@handle"/>
- </xsl:call-template>
+ <xsl:apply-templates select="$root/articles/entry[@handle = $handle]" mode="resolve"/>
</div>
</xsl:otherwise>
</xsl:choose>