1. Computing

The Framework

By

Before we start plugging gems in and taking user input, let's get a bit of framework up. This includes a basic page layout the beginnings of an index page. The code presented in this article is completely without CSS styling and layout, as well as images as this is beyond the scope of this article.

In all, this is nothing you haven't seen before if you've read the previous article on Using Haml with Sinatra.

#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'

get '/' do
  haml :index
end

__END__
@@ layout
%html
  %head
    %title Network Tools
  %body
    #header
      %h1 Network Tools
    #content
      =yield

@@ index
%p
  Welcome to Network Tools. Below is a list
  of the tools available.
  1. About.com
  2. Computing
  3. Ruby
  4. Tutorials
  5. Sinatra
  6. The Framework

©2014 About.com. All rights reserved.