Class: N::XSLTShader
Overview
Apply an XSL transformation to the script code. There is no need to keep post xsl. I can reuse the same xsl by calling transform again.
Instance Attribute Summary collapse
-
#mtime ⇒ Object
readonly
Last modified time of the xslt.
-
#name ⇒ Object
readonly
The name.
-
#xsl_filename ⇒ Object
readonly
The xslt filename.
-
#xslt ⇒ Object
readonly
The xslt transformer.
Attributes inherited from Shader
Instance Method Summary collapse
-
#initialize(xsl_filename, next_stage = nil) ⇒ XSLTShader
constructor
A new instance of XSLTShader.
-
#process(hash, text) ⇒ Object
Transform the given text.
Methods inherited from Shader
Constructor Details
#initialize(xsl_filename, next_stage = nil) ⇒ XSLTShader
Returns a new instance of XSLTShader.
175 176 177 178 179 180 181 182 183 184 |
# File 'lib/nitro/shaders.rb', line 175 def initialize(xsl_filename, next_stage = nil) # leave this require here. only inlcude the xslt # library if the project needs it. require "xml/xslt" @name = File.basename(xsl_filename, '.*') @xsl_filename = xsl_filename @xslt = XML::XSLT.new @next_stage = next_stage end |
Instance Attribute Details
#mtime ⇒ Object (readonly)
Last modified time of the xslt.
173 174 175 |
# File 'lib/nitro/shaders.rb', line 173 def mtime @mtime end |
#name ⇒ Object (readonly)
The name
161 162 163 |
# File 'lib/nitro/shaders.rb', line 161 def name @name end |
#xsl_filename ⇒ Object (readonly)
The xslt filename.
165 166 167 |
# File 'lib/nitro/shaders.rb', line 165 def xsl_filename @xsl_filename end |
#xslt ⇒ Object (readonly)
The xslt transformer.
169 170 171 |
# File 'lib/nitro/shaders.rb', line 169 def xslt @xslt end |
Instance Method Details
#process(hash, text) ⇒ Object
Transform the given text.
188 189 190 191 192 193 194 |
# File 'lib/nitro/shaders.rb', line 188 def process(hash, text) parse_xsl() @xslt.xml = text hash += @name process_next(hash, xslt.serve) end |