A line starting with # in an Erb program is not
interpreted as a comment and displayed.
This is annoying, since the first line of a CGI program
must start with a #! line. Is the only solution to use
the Erb Class within a ruby program?
I use erb.bat in a Ruby 1.8 win32 installation.
A simple example is:
#!E:/ruby/bin/erb.bat
<%print "Content-type: text/html\r\n\r\n"%>
<HTML>
<HEAD>
<TITLE>Erb Test</TITLE>
<CENTER><H1>Erb Test</H1><b>
<%="The current time is #{Time.now}" %> </CENTER> #This is a comment
</HEAD>
</HTML>
A line starting with # in an Erb program is not
interpreted as a comment and displayed.
This is annoying, since the first line of a CGI program
must start with a #! line. Is the only solution to use
the Erb Class within a ruby program?
I use erb.bat in a Ruby 1.8 win32 installation.
A simple example is:
#!E:/ruby/bin/erb.bat
<%print "Content-type: text/html\r\n\r\n"%>
<HTML>
<HEAD>
<TITLE>Erb Test</TITLE>
<CENTER><H1>Erb Test</H1><b>
<%="The current time is #{Time.now}" %> </CENTER> #This is a comment
</HEAD>
</HTML>
We can use the HTML tags <!...> and the Erb tags <%#...%>
for comments between <HTML> and </HTML>.
So the only problem is for the first line.
When I changed \ruby\bin\erb following your advice
and changed \ruby\bin\erb.bat to @echo off
E:\ruby\bin\ruby.exe "E:\ruby\bin\erb"
"--skip-first" %2 %3 %4 %5 %6 %7 %8 %9
then src = $<.read became an endless loop.
Therefore, I simply added
src.sub!(/\A#!.*\n/, "")
to the original \ruby\bin\erb and kept others intact.
Then it worked.