Skip to content

API sites: Consistent styling for examples #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions tasks/jquery-xml/entries2html-base.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,17 @@
</xsl:for-each>
</ul>
</xsl:if>
<xsl:if test="@example-value | example-value">
<xsl:call-template name="widget-option-examples">
<xsl:with-param name="widget-name" select="$widget-name"/>
</xsl:call-template>
<xsl:if test="descendant::example | @example-value | example-value">
<strong>Code examples:</strong>
<xsl:if test="@example-value | example-value">
<xsl:call-template name="widget-option-examples">
<xsl:with-param name="widget-name" select="$widget-name"/>
</xsl:call-template>
</xsl:if>
<xsl:apply-templates select="descendant::example">
<xsl:with-param name="number-examples" select="count(example)"/>
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates select="example">
<xsl:with-param name="number-examples" select="count(example)"/>
</xsl:apply-templates>
</div>
</xsl:for-each>
</section>
Expand Down Expand Up @@ -581,8 +584,6 @@
<xsl:template name="widget-option-examples">
<xsl:param name="widget-name"/>

<strong>Code examples:</strong>

<p>Initialize the <xsl:value-of select="$widget-name"/> with the <code><xsl:value-of select="@name"/></code> option specified:</p>
<pre><code data-lang="javascript">
<xsl:text>$( ".selector" ).</xsl:text>
Expand Down Expand Up @@ -656,17 +657,16 @@
<xsl:value-of select="position() - 1"/>
</xsl:attribute>

<h4>
<xsl:if test="$number-examples &gt; 1">Example: </xsl:if>
<span class="desc"><xsl:apply-templates select="desc"/></span>
</h4>
<p>
<xsl:apply-templates select="desc"/>
</p>
<pre><code data-linenum="true">
<xsl:choose>
<xsl:when test="html">
<xsl:call-template name="example-code"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="code/text()"/>
<xsl:apply-templates select="code"/>
</xsl:otherwise>
</xsl:choose>
</code></pre>
Expand Down Expand Up @@ -1132,9 +1132,9 @@
</div>
</xsl:template>

<!-- <desc> and <longdesc> support <placeholder name="foo"> to replace the
<!-- Some elements support <placeholder name="foo"> to replace the
placeholder with @foo from the <entry> -->
<xsl:template match="desc|longdesc">
<xsl:template match="desc|longdesc|code">
<xsl:param name="entry-name"/>
<xsl:apply-templates select="./node()">
<xsl:with-param name="entry-name" select="$entry-name"/>
Expand Down