Class: Nanoc::Filters::XSL
- Inherits:
-
Nanoc::Filter
- Object
- Context
- Nanoc::Filter
- Nanoc::Filters::XSL
- Defined in:
- lib/nanoc/filters/xsl.rb
Overview
Constant Summary
Constant Summary
Constants inherited from Nanoc::Filter
Nanoc::Filter::TMP_BINARY_ITEMS_DIR
Instance Attribute Summary
Attributes inherited from Nanoc::Filter
Instance Method Summary (collapse)
Methods inherited from Nanoc::Filter
#depend_on, #filename, from_binary?, #initialize, #output_filename, requires, setup, #setup_and_run, to_binary?, type
Methods included from PluginRegistry::PluginMethods
#all, #identifier, #identifiers, #named, #register
Methods inherited from Context
Constructor Details
This class inherits a constructor from Nanoc::Filter
Instance Method Details
- (String) run(_content, params = {})
Runs the item content through an XSLT stylesheet using Nokogiri.
This filter can only be run for layouts, because it will need both the XML to convert (= the item content) as well as the XSLT stylesheet (= the layout content).
Additional parameters can be passed to the layout call. These parameters
will be turned into xsl:param
elements.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nanoc/filters/xsl.rb', line 34 def run(_content, params = {}) Nanoc::Extra::JRubyNokogiriWarner.check_and_warn if assigns[:layout].nil? raise 'The XSL filter can only be run as a layout' end xml = ::Nokogiri::XML(assigns[:content]) xsl = ::Nokogiri::XSLT(assigns[:layout].raw_content) xsl.apply_to(xml, ::Nokogiri::XSLT.quote_params(params)) end |