[Nitro] Can nitro be used with eruby?

James Britt james_b at neurogami.com
Sun Jun 11 13:44:43 EDT 2006

Fabian Buch wrote:

> Well, Nitro is definitely not the lightest tool, it's a very complex  
> and high-level framework. The lightest would maybe be mod_ruby, eruby  
> or PHP (if you're not limited to the Ruby programming language).

Well, to be fair, while there are some complex parts in Nitro, one can 
safely ignore most of it and do simple, template-driven Web sites quite 
easily.  That, for me, is part of the appeal.  Use what you want, ignore 
the rest.

Here's an erb example:

# ---------- File run.rb --------------
#!/usr/bin/env ruby
require 'nitro'
require 'erb'
require 'controller/main'


# ----------------------------------

#--- File src/controller/main/rb ---

class Main
   def index
     @title = "Erb Example"
     @body = "<h1>Hello from Nitro</h1>"


   def emit
     template = ERB.new( html )

   def html
     "<html><head><title><%=@title %></title></head>
     <body><%= @body %></body></html>"

# ----------------------------------

James Britt

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://web2.0validator.com    - We're the Dot in Web 2.0

More information about the Nitro-general mailing list