The ease of PHP with the power of Ruby

#!/usr/bin/ruby                                                                 
require 'rubyhp'
__END__
<html>
 <body>
  <% cgi.params.each do |key, value| %>
   <%= key %>: <%= value %><br />
  <% end %>
  <% if cgi.params.empty? %>
   Sorry, please enter some cgi parameters. How about "?foo=baz"?
  <% end %>
 </body>
</html>

Christopher Cyll has put together a great little example of how to quickly create templated Web pages with Ruby without requiring any frameworks. It relies on CGI, but sometimes that's all you need, and it makes throwing together tiny Ruby-powered Web pages possible as easy as creating a simple PHP page.

Comments

  1. Aníbal Rojas ·

    What about:

    http://www.hiveminds.co.uk/node/3105

    It is a little bit more elaborated, but almost the same. And I agree with you, not everything is a "application" there is a lot of space for quick n' dirty small scripts

  2. Christoffer Sawicki ·

    A slightly better way:
    http://termos.vemod.net/making-ruby-into-php-take-two

  3. James ·

    One of the things I like about Ruby's Nitro Web framework is that it makes it very easy to build dirt-simple, ASP/PHP-like pages, while providing a good migration path to more a sophisticated ORM/MVC-style architecture if you need that as the application evolves.

    http://nitroproject.org/