Forum: Ruby questions about ruby cgi

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Larry W. (Guest)
on 2005-12-17 16:54
(Received via mailing list)
I'm trying to use the cgi library to generate some html that will later
get
run through erb.

The problem i'm having is that if i try to use the cgi.text_field method
it
automatically escapes anything passed in as the value. That means an erb
instruction like "<%= get_a_value_ here %>" gets escaped and erb ignores
it.

I looked at the cgi source, but the method that does the work, input(),
isn't defined in the main file.

I have two questions:
1. Where would i find the file where the instance method input is
defined?
2. Is there an easier way around this than trying to hack the cgi
library?

thanks.
unknown (Guest)
on 2005-12-17 23:19
(Received via mailing list)
On Sat, 17 Dec 2005, Larry W. wrote:

> I have two questions:
> 1. Where would i find the file where the instance method input is defined?
> 2. Is there an easier way around this than trying to hack the cgi library?

eparklabs will be releasing this in the next few days:

      [ahoward@localhost xx-0.0.0]$ cat a.rb
      require "xx"

      class Table < ::Array
        include XX::XHTML

        def to_xhtml
          xhtml_{
            html_{
              head_{ title_{ "table demo" } }

              h1_(:style => :sweet){ "this is a table " }

              h_{ "<malformed html & open tags if you must" }

              table_(:width => 42, :height => 42){
                each{|row|
                  tr_{ row.each{|cell| td_ cell } }
                }
              }
            }
          }
        end
      end

      table = Table[ %w( 0 1 2 ), %w( a b c ) ]

      puts table.to_xhtml


      [ahoward@localhost xx-0.0.0]$ ruby -I./lib a.rb
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html lang='en' xml:lang='en'
xmlns='http://www.w3.org/1999/xhtml'>
        <head>
          <title>table demo</title>
        </head>
        <h1 style='sweet'>this is a table </h1><malformed html & open
tags if you must
        <table height='42' width='42'>
          <tr>
            <td>0</td>
            <td>1</td>
            <td>2</td>
          </tr>
          <tr>
            <td>a</td>
            <td>b</td>
            <td>c</td>
          </tr>
        </table>
      </html>



perhaps i could send you a version offline to test?

-a
--
===============================================================================
| email : ara [dot] t [dot] howard [at] eparklabs [dot] com
| uri   : eparklabs.com
| all happiness comes from the desire for others to be happy.  all misery
| comes from the desire for oneself to be happy.
| -- bodhicaryavatara
===============================================================================
Ezra Z. (Guest)
on 2005-12-18 02:35
(Received via mailing list)
there an easier way around this than trying to hack the cgi library?
>          xhtml_{
>                }
>
>        <table height='42' width='42'>
>        </table>
>      </html>
>
>
>
> perhaps i could send you a version offline to test?
>
> -a


Ara-

	I like the looks of that a lot. Can you send me a copy of list? I
will test and give feedback.

Cheers-
-Ezra
This topic is locked and can not be replied to.