Skip to content
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

XSL filter transforms the stylesheet's (layout's) content, not the item's #399

Closed
simonsouth opened this Issue Mar 15, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@simonsouth
Copy link
Contributor

commented Mar 15, 2014

When invoked, the XSL filter attempts to transform the stylesheet's own content using the stylesheet and not the item's. This is easy to demonstrate using a stylesheet that merely duplicates its input, i.e.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">
  <xsl:template match="/">
    <xsl:copy-of select="/"/>
  </xsl:template>
</xsl:stylesheet>

The result will be the stylesheet itself embedded in the output, not the item's content as you'd expect.

The problem is in Nanoc::Filter::XSL.run, which uses the value of the content parameter passed to it as the content to transform. But when invoked as a layout, and the XSL filter is only ever invoked as a layout, this parameter contains the layout's content and not the item's. The item's content is available as assigns[:content] instead.

I've fixed this problem and updated the test cases locally and will be submitting a pull request shortly.

ddfreyne added a commit that referenced this issue Mar 15, 2014

Merge pull request #401 from simonsouth/bug/make-xsl-filter-process-i…
…tem-content

Make XSL filter transform the item, not the layout - issue #399
@ddfreyne

This comment has been minimized.

Copy link
Member

commented Mar 15, 2014

Fixed. Thanks!

It’s also in the release notes now: d7e25fd

@ddfreyne ddfreyne closed this Mar 15, 2014

@ddfreyne ddfreyne added the bug/fix label Mar 15, 2014

@simonsouth

This comment has been minimized.

Copy link
Contributor Author

commented Mar 15, 2014

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.