[Takao Ueda <takaoueda / juno.com>, 2004-11-19 16.23 CET] > 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? How about this patch? (Option "--skip-first" skips first line if starts with "#!"). --- /usr/local/bin/erb~ 2004-11-19 23:15:59.000000000 +0100 +++ /usr/local/bin/erb 2004-11-19 23:15:59.000000000 +0100 @@ -43,7 +43,7 @@ def run(factory=ERB) trim_mode = 0 - disable_percent = false + disable_percent = skip_first = false begin while switch = ARGV.switch case switch @@ -88,6 +88,8 @@ end when '-P' disable_percent = true + when '--skip-first' + skip_first = true when '--help' raise "print this help" else @@ -113,6 +115,7 @@ end src = $<.read + src.sub!(/\A#!.*\n/, "") if skip_first exit 2 unless src trim = trim_mode_opt(trim_mode, disable_percent) erb = factory.new(src.untaint, safe_level, trim)