Posted by Tom on 2006-11-10
Hello World will never get old for me. What more could you need to get yourself oriented in a new technology? I remember the first time I managed to string the whole J2EE stack together. All that technology – JNDI, RMI, EJB… All just to get “Hello World” on the screen. Hmmm. Can’t say I miss that too much.
Where was I?
Oh yes. One of the main features of Hobo is DRYML - an new template engine that extends ERB with user-defined tags. Thats right: extends. DRYML templates can use erb scriptlets just like regular RHTML templates.
We’re going to create a custom tag
<hello> which will render - you
guessed it - “Hello World” on the page. Obviously, the real goal here is to get
Hobo installed and verify that it’s running.
To run Hobo you need Rails 1.2, which at the time of writing is available as release-candidate 1. Install it like this:
gem install rails --source http://gems.rubyonrails.org -y
To install Hobo into a new Rails app, simply:
$ rails hobo_hello_world $ cd hobo_hello_world $ ./script/plugin install svn://hobocentral.net/hobo/trunk
Next, there are one or two directories and files that Hobo expects to find. Create these with the handy generator:
$ ./script/generate hobo create app/views/hobolib create app/views/hobolib/themes create app/views/hobolib/application.dryml
OK, Hobo is now at your service! Before we can have a Hello World view, of course, we’ll need a controller:
$ ./script/generate controller hello
No need to edit that. We’ll just go straight for the view.
<def tag="hello">Hello World!</def> <p>Here it comes... Can you stand it??!</p> <p style="font-size: 500%"> <hello/> </p>
That’s it. Start your engines:
And browse yourself over to