From: Larry White Date: 2005-12-10T12:19:16+09:00 Subject: Re: Customizing erb's recognized tags that might be a good solution. i'll give it a try. thanks. On 12/9/05, James Britt wrote: > 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 < 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 =~ / l.gsub!( ' 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 > >