questions about ruby cgi

L

Larry White

------=_Part_21298_6174007.1134830999868
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 "<%=3D 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.

------=_Part_21298_6174007.1134830999868--
 
A

ara.t.howard

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?

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
===============================================================================
 
E

Ezra Zygmuntowicz

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


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top