Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change html attributes in ruby cgi

Tags:

html

ruby

cgi

How do I add an HTML attribute to a ruby cgi element. I saw an example similar to the one commented out below but it gives me the following error:

[Tue Dec 17 08:38:42 2013] [error] [client 127.0.0.1] Premature end of script headers: test1.rb, referer: http://localhost/test.rb
[Tue Dec 17 08:38:42 2013] [error] [client 127.0.0.1] C:/wamp/www/htdocs/test1.rb:19: syntax error, unexpected '\\n', expecting tASSOC\r, referer: http://localhost/test.rb

I searched the web for other examples with no success.

What am I missing? It seems like this should be fairly straightforward.

#!"C:\Ruby193\bin\ruby.exe"
#!/Ruby193/bin/ruby
require "cgi"
require "to_bool"
require 'net/telnet'
require 'pp'
cgi = CGI.new("html4")

cgi.out {
 cgi.html{
  cgi.head{ "\n"+cgi.title{"Second Panel"} } +
   cgi.body { "\n"+
    cgi.form {"\n"+
        cgi.h1{"Params1   "} + "\n" +
  #     cgi.table(border=>"1") { cgi.tr{cgi.td {"Artistxx"} + cgi.td{"Album"} +            cgi.td{"Albuxm"}}  +
        cgi.table{ cgi.tr{cgi.td {"Artistxx"} + cgi.td{"Album"} + cgi.td{"Albuxm"}}  +
        cgi.tr{cgi.td {"Artistxx"} + cgi.td{"Album"} + cgi.td{"Albuxm"}}  +
        cgi.tr{cgi.td {"Artistxx"} + cgi.td{"Album"} + cgi.td{"Albuxm"}} 
        } + "\n" +
            cgi.submit
         } 
      } 
   } 
} 
like image 564
Paul Palmer Avatar asked Jan 27 '26 21:01

Paul Palmer


1 Answers

The trouble is here:

cgi.table(border=>"1") { cgi.tr{cgi.td {"Artistxx"} + cgi.td{"Album"} +            cgi.td{"Albuxm"}}  +

To see where, let's format it using multiple lines:

cgi.table(border=>"1") {
  cgi.tr {
    cgi.td {"Artistxx"} +
    cgi.td{"Album"} +
    cgi.td{"Albuxm"}
  }  +

It looks like there's a missing }. This should be:

cgi.table(border=>"1") {
  cgi.tr {
    cgi.td {"Artistxx"} +
    cgi.td{"Album"} +
    cgi.td{"Albuxm"}
  }
}  +

Also, this:

cgi.table(border=>"1") {

needs to have border quoted:

cgi.table("border"=>"1") {
like image 134
Wayne Conrad Avatar answered Jan 29 '26 11:01

Wayne Conrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!