Konstantin Konstantin - 2 years ago 77
Ruby Question

Is it possible to mix Ruby code and HTML like in PHP?

I would like to generate a HTML page with Ruby, and I am curious if it is possible to mix somehow the static part HTML and the Ruby statements which generate the dynamic parts. Is there a godd technique for doing this?

Answer Source

Yes it is possible. change your file name to file_name.html.erb

<form action="<%= ruby here %>" method="get" >
  <%= rand()  %> <!-- Pure ruby here -->

  <%= submit_tag "Search", :name => nil%> <!-- options in ruby -->
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download