Skip to content

Instantly share code, notes, and snippets.

@ctbarber
Created March 27, 2017 19:35
Show Gist options
  • Save ctbarber/634eaacbfd01765fecc7500d56efa4de to your computer and use it in GitHub Desktop.
Save ctbarber/634eaacbfd01765fecc7500d56efa4de to your computer and use it in GitHub Desktop.
<!-- begin template match for Tabs snippet -->
<xsl:template match="table[@class='snippet-tabs']" mode="copy">
<xsl:variable name="tabs-id" select="generate-id()" />
<xsl:variable name="tabs-orientation">
<xsl:choose>
<xsl:when test="lower-case(tbody/tr[2]/td[2]/node()) = 'vertical'">
<xsl:text> vertical</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> horizontal</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="tabs-size">
<xsl:choose>
<xsl:when test="$tabs-orientation = ' horizontal'">
<xsl:text>medium-12</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'small'">
<xsl:text>small-4 large-2</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'medium'">
<xsl:text>medium-3</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'large'">
<xsl:text>medium-4</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'xlarge'">
<xsl:text>medium-5</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>medium-3</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="tabs-content-size">
<xsl:choose>
<xsl:when test="$tabs-orientation = ' horizontal'">
<xsl:text>medium-12</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'small'">
<xsl:text>small-8 large-10</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'medium'">
<xsl:text>medium-9</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'large'">
<xsl:text>medium-8</xsl:text>
</xsl:when>
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'xlarge'">
<xsl:text>medium-7</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>medium-9</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="row collapse">
<div class="{$tabs-size} columns">
<xsl:value-of select="concat('&lt;ul class=&quot;tabs',$tabs-orientation, '&quot; data-tabs=&quot;data-tabs&quot; id=&quot;',$tabs-id,'&quot;&gt;')" disable-output-escaping="yes"/>
<xsl:for-each select="tbody/tr">
<xsl:if test="position() = 6">
<li class="tabs-title is-active">
<a href="#{$tabs-id}-{position()}" aria-selected="true"><xsl:apply-templates select="td[1]/node()" mode="copy"/></a>
</li>
</xsl:if>
<xsl:if test="position() > 6">
<li class="tabs-title">
<a href="#{$tabs-id}-{position()}"><xsl:apply-templates select="td[1]/node()" mode="copy"/></a>
</li>
</xsl:if>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
</div>
<div class="{$tabs-content-size} columns">
<xsl:value-of select="concat('&lt;div class=&quot;tabs-content',$tabs-orientation, '&quot; data-tabs-content=&quot;',$tabs-id,'&quot;&gt;')" disable-output-escaping="yes"/>
<xsl:for-each select="tbody/tr">
<xsl:if test="position() = 6">
<div class="tabs-panel is-active" id="{$tabs-id}-{position()}">
<xsl:apply-templates select="td[2]/node()" mode="copy"/>
</div>
</xsl:if>
<xsl:if test="position() > 6">
<div class="tabs-panel" id="{$tabs-id}-{position()}">
<xsl:apply-templates select="td[2]/node()" mode="copy"/>
</div>
</xsl:if>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">&lt;/div&gt;</xsl:text>
</div>
</div>
</xsl:template>
<!-- end template match for Tabs snippet -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment