Class: Nitro::XSLTransform

Inherits:
Object
  • Object
show all
Defined in:
lib/nitro/compiler/xslt.rb

Overview

Pre-applies an XSL transformation to the template file to generate the final template file. Due to preproccessing, the transformation comes for free.

Constant Summary collapse

@@sync =
Sync.new

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.xsl_filenameObject (readonly)

The xslt filename.



18
19
20
# File 'lib/nitro/compiler/xslt.rb', line 18

def xsl_filename
  @xsl_filename
end

.xsltObject (readonly)

The xslt transformer.



22
23
24
# File 'lib/nitro/compiler/xslt.rb', line 22

def xslt
  @xslt
end

Class Method Details

.initialize(xsl_filename, next_stage = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/nitro/compiler/xslt.rb', line 24

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

.transform(text, compiler = nil) ⇒ Object

Transform the given xml.



39
40
41
42
43
44
45
# File 'lib/nitro/compiler/xslt.rb', line 39

def transform(text, compiler = nil)      
  parse_xsl()
  @xslt.xml = text
  hash += @name
  Logger.debug "Applying xsl '#{@xsl_filename}' to template" if $DBG
  process_next(hash, xslt.serve)
end