user input - spit code to browser

Hi, I am having trouble figuring out how to do this...

I am developing a new ruby on rails project and
I am trying figure out how to write code so that when a user inputs
their info into a form and they click on submit (or in my case, "get
code")
the code generated will show in the browser so that they can copy and
paste that code into their own html doc.

is there a way to do this with ruby? If so, I would greatly appreciate
any
help on this :slight_smile:

thanks in advance!

Jeremy

Whatever you put in the view will be shown in the browser. Perhaps
you can clarify how your situation is different than normal?

Hassan Schroeder wrote:

I am developing a new ruby on rails project and
I am trying figure out how to write code so that when a user inputs
their info into a form and they click on submit (or in my case, "get
code")
the code generated will show in the browser so that they can copy and
paste that code into their own html doc.

Whatever you put in the view will be shown in the browser. Perhaps
you can clarify how your situation is different than normal?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

Hi there, I apologize.

What i mean is.. you have a basic page with a form on it. the user
inputs the info into the form. Then when they click on the submit
button.. it produces the information into code viewable for the user to
see.

an example is if i had a page where a user could enter a size, width and
upload a picture into the form that is available on that page.. then
they hit the submit button. it would generate the code in the browser to
tell the user what code they would need to put it on their own html doc.
much like this code...
so they enter their information into the form.. they hit the submit
button and this is what is produced on their browser window.
<a href="rubyForum"><img src="http://www.rubyforum.com" /></a>

I hope that clears things a little :slight_smile:

Thanks for your help.

an example is if i had a page where a user could enter a size, width and
upload a picture into the form that is available on that page.. then
they hit the submit button. it would generate the code in the browser to
tell the user what code they would need to put it on their own html doc.
much like this code...

So you're not talking about code, you're talking about markup.
There /is/ a difference :slight_smile:

... and this is what is produced on their browser window.
<a href="rubyForum"><img src="http://www.rubyforum.com" /></a>

require 'cgi'
example = '<a href="rubyForum"><img src="http://www.rubyforum.com" /></a>'
CGI.escapeHTML(example)

is probably what you're looking for. There are probably alternatives, but
I'm new to RoR too :slight_smile:

HTH,

i want it to act ALOT like this form at the bottom of the page

http://www.mozilla.org/docs/web-developer/css1technote/css1tojs.html

So you're not talking about code, you're talking about markup.
There /is/ a difference :slight_smile:

... and this is what is produced on their browser window.
<a href="rubyForum"><img src="http://www.rubyforum.com" /></a>

require 'cgi'
example = '<a href="rubyForum"><img src="http://www.rubyforum.com"
/></a>'
CGI.escapeHTML(example)

is probably what you're looking for. There are probably alternatives,
but
I'm new to RoR too :slight_smile:

HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

Oh yeah, duh...lol i guess i should have said markup.. sorry bout that

Okay I will try that :slight_smile: thanks very much for your help!