Konstantin Konstantin - 5 months ago 9
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?


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