Hi Michael,

Here is a quick and dirty method to create ColdFusion type tags in an
eruby-like implementation.  Hope you can follow it - I've left some
hopefully obvious pseudocode methods undefined.  Also, some of the
mechanisms like variable storage I've given a really trivial implementation
of.  You would obviously design a session mechanism.

1)  Use <% %> to wrap a tag.  Put only one tag inside each <%...%> pair.

2)  Treat Cold fusion like tags as XMLRPCs of sorts.

3)  Create an command pattern interface for a generic ColdFusionProc -
something like
def execute(requestObject, responseObject, variableStorage)
where requestObject gives all the information for the request,
responseObject that is an output stream, variableStorage allows you to
store/retrieve variables for this page.

4)  For each Cold Fusion tag, create a separate class that implements
ColdFusionFunction and implement it.  Also, create a PlainText class that
implements Cold Fusion Function and implements it.  Have each class act as
its own class factory.

5)  In your ColdFusion embedded ruby, precompile a page like this:
cold = ColdFusionParser.new
cold.parse <<-INP
Top of web page
<%<CFTAG attr1="55" attr2="hack">
Some data
</CFTAG>
%>
INP

class ColdFusionParser
  @@functionFactories = hash.new
  # load with a factory for each function here or in helper class
  @@functionClasses ["CFTAG"] = CFTAG
def initialize
  @requestObject = #design a class to hold request parameters
  @responseObject = "" # should be a stream you can write to
  def responseObject.write(str)
    self << str
  end
  @variableStorage = Hash.new
  @xmlParser = # new xmlParser NQXML for example
end

def compile(text)
  compiledFunctions = Array.new   #(use a list or tree typically)
  tokens = tokenize(text)
  tokens.each begin |token|
    newFunction = nil
    if isWrappedInPercentTags(token)
       DomElement xml = xmlParser.parse(stripOuterTags(token) )
       newFunction = getColdFusionFunction(xml)
    else
      newFunction = PlainText.new(token)
    end
    compiledFunctions.push newFunction
  end
  return compiledFunctions
end
private :compile

def parse(text)
  compiledFunctions = compile(text)
  compiledFunctions.each do |function|
     function.evaluate(@requestObject, @responseObject, @variableStorage)
  end
end

def tokenize(text)
  tokens = Array.new
  # tokenize text so you now have (from the example
  # token1 -> Top of web page
  # token2 -> <%<CFTAG ...%>
  # token3 -> Bottom of web page
  return tokens
end
private :tokenize

def getColdFusionFunction(xmlElement)

end

module ColdFusionFunction
  def execute(requestObject, responseObject, variableStorage)
  end

  def initialize(xmlElement)
  end
end

class CFTAG
  include ColdFusionProc

  def initialize (xmlElement)
    # set up instance variables, etc.
  end
  def execute(requestObject, responseObject, variableStorage)
    # do things like
      variableStorage['qQueryReturn'] =
  end
end