How to integrate Ruby code with HTML?

Dear All:

I am using ruby for automation test scripts. Now I want to integrate Ruby code with HTML. How can I achieve this?

Thanks in advance.

What do you mean integrate ruby code with html? just print the html markup if you want to output html. like this ,

puts ‘

hello ruby,

it will outputs as a string when you in terminal, except you work on browser that renders the string to html automatically.

You can use ERB. Take a look: http://ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html

Hi,

I meant can I call the Ruby script from the HTML code just like Javascript?

I want to call ruby script by clicking the button. Is it possible?

Thanks

Hi,

I meant can I call the Ruby script from the HTML code just like Javascript?

I want to call ruby script by clicking the button. Is it possible?

You can’t run a ruby script on the client side. You need to use ajax to contact the

server and then run the script and then return a response to the client side.