Larry White wrote:
> Hi
> 
> Does anyone know if it's possible to change the tags that erb
> recognizes so that for instance, I can have it replace on #{} instead
> of <%= %>  ?
> 
> If so, could you point me an example of how it's done?

I wrote a hack that overrides IO.read.  When IO grabs the file, it 
checks the file extension;  if it's an erb template, it replaces <? ?> 
(with some variants) markup with <% %> before passing along the content.

It was a Good Enough sort of thing for the circumstances.


class IO
   class <<self
     alias real_read read
   end

   def IO.read( *args )
     return IO.real_read( *args ) unless args[0].to_s =~ /\.rhtml/i
     text = IO.real_read( *args )
     s = ''
     text.each_line(  ) { |l|
       next if l =~ /<?xml/
      l.gsub!( '<?eq', '<%=')
      l.gsub!( '<? ', '<% ')
      l.gsub!( '?>', '%>')
      s << "#{l}\n"
     }
     s
   end
end


James



-- 

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com     - Playing with Better Toys
http://www.30secondrule.com   - Building Better Tools