Class: N::XSLTShader

Inherits:
Shader show all
Defined in:
lib/nitro/shaders.rb

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

Attributes inherited from Shader

#next_stage

Instance Method Summary collapse

Methods inherited from Shader

#<<, #process_next

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

#mtimeObject (readonly)

Last modified time of the xslt.



173
174
175
# File 'lib/nitro/shaders.rb', line 173

def mtime
  @mtime
end

#nameObject (readonly)

The name



161
162
163
# File 'lib/nitro/shaders.rb', line 161

def name
  @name
end

#xsl_filenameObject (readonly)

The xslt filename.



165
166
167
# File 'lib/nitro/shaders.rb', line 165

def xsl_filename
  @xsl_filename
end

#xsltObject (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