Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Ruby 1.8.7: ERB is broken
Charlie Marx
1/3/2009 6:32:00 PM
Actually comments will work in 1.8.7, but only with a specific, more
limited syntax than shown in the original example above.
Here is a relevant portion from the inline documentation for ERB:
| ERB recognizes certain tags in the provided template and converts them based on the rules below:
|
| <% Ruby code -- inline with output %>
| <%= Ruby expression -- replace with result %>
| <%# comment -- ignored -- useful in testing %>
| % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
| %% replaced with % if first thing on a line and % processing is used
| <%% or %%> -- replace with <% or %> respectively
So comments ARE allowed when the whole embedded expression is a comment,
i.e.:
<%# this is good comment %>
<% n=1 # this is a bad comment %>
If your 'bad comments' are consistent in their usage of whitespace
around the hash mark, then it ought to be easy to do a grep
search-and-replace to change all your bad comments to look like this,
which WILL work in Ruby 1.8.7:
<% n=1 %><%# this is the fixed comment %>
--
Posted via
http://www.ruby-...
.
1 Answer
Jordan Brough
1/28/2009 1:31:00 PM
0
Comments aren't supported, only comment tags are.
ruby -v -rerb -e 'p ERB.new("<%# test %>foobar").result'
correctly gives 'foobar'. while
ruby -v -rerb -e 'p ERB.new("<% # test %>foobar").result'
gives an empty string (in 1.8.6 and 1.8.7).
Charlie Marx wrote:
> Actually comments will work in 1.8.7, but only with a specific, more
> limited syntax than shown in the original example above.
>
> So comments ARE allowed when the whole embedded expression is a comment,
>
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Ruby 1.8.7: ERB is broken
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password