[Nitro] replacement transformer

Dimitri Aivaliotis aglarond at gmail.com
Tue Apr 11 03:02:17 EDT 2006

Hi All,

I was looking through the source code, and oxyliquit, to see if I
could find something like this:

class MyController < Nitro::Controller
  def index
    replace = Nitro::ReplaceTransformer.new( 'default.xhtml' )
    replace.div( :content, :mylink )
    replace.a( :href => "/mylink", :class => "current" )

Meaning basically, that you have a map routing from "/mylink" to
MyController.  The 'index' page is called, and transforms the
'default.xhtml' template in the following way:

- the content of the 'div' with 'id'="content" gets replaced with the
contents of a file 'mylink' (located in a globally-defined place, like
Nitro.transformer_root or something)
- the 'a' with 'href'="/mylink" gets the 'class' attribute added to
it, with value "current"
- important: both the 'div' and the 'a' tags themselves remain in the
transformed file, for eventual processing by another compiler in the
pipeline or delivery to a cache file/web browser

Does anyone know how to do something like this with the current
(repo-version) Nitro?

I just wanted to check before I go re-inventing the wheel.  I know
that this type of behavior has been requested by others, I just don't
recall if it's been implemented yet.


- Dimitri

More information about the Nitro-general mailing list