Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!-- begin template match for Accordion snippet -->
<xsl:template match="table[@class='snippet-accordion']" mode="copy">
<xsl:variable name="multiple-panes">
<xsl:if test="lower-case(tbody/tr[2]/td[2]/node()) != 'no'">
<xsl:text>data-multi-expand="true" </xsl:text>
</xsl:if>
</xsl:variable>
<xsl:variable name="all-closed">
<xsl:if test="lower-case(tbody/tr[3]/td[2]/node()) = 'yes'">
<xsl:text>data-allow-all-closed="true"</xsl:text>
</xsl:if>
</xsl:variable>
<xsl:variable name="start-closed">
<xsl:if test="lower-case(tbody/tr[4]/td[2]/node()) = 'no'">
<xsl:text>is-active</xsl:text>
</xsl:if>
</xsl:variable>
<xsl:value-of select="concat('&lt;div class=&quot;accordion&quot; data-accordion=&quot;data-accordion&quot; ',$multiple-panes,$all-closed,'&gt;')" disable-output-escaping="yes"/>
<xsl:for-each select="tbody/tr">
<xsl:if test="position() = 7">
<div class="accordion-item {$start-closed}" data-accordion-item="data-accordion-item">
<a href="#" class="accordion-title"><xsl:apply-templates select="td[1]/node()" mode="copy"/></a>
<div class="accordion-content" data-tab-content="data-tab-content">
<xsl:apply-templates select="td[2]/node()" mode="copy"/>
</div>
</div>
</xsl:if>
<xsl:if test="position() > 7">
<div class="accordion-item" data-accordion-item="data-accordion-item">
<a href="#" class="accordion-title"><xsl:apply-templates select="td[1]/node()" mode="copy"/></a>
<div class="accordion-content" data-tab-content="data-tab-content">
<xsl:apply-templates select="td[2]/node()" mode="copy"/>
</div>
</div>
</xsl:if>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">&lt;/div&gt;</xsl:text>
</xsl:template>
<!-- end template match for Accordion snippet -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment