Skip to content

Commit

Permalink
Working on haml examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jc00ke committed Mar 2, 2010
1 parent 4d20d5d commit 22e2efd
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 6 deletions.
22 changes: 22 additions & 0 deletions example/in_file_templates.rb
@@ -0,0 +1,22 @@
require 'rubygems'
require 'sinatra'
require 'haml'

set :haml, { :format => :html5 }

get '/' do
haml :index
end

__END__

@@ layout
!!!
%html
%head
%title PDXRB RULES!
%body= yield

@@ index
#index
Um, hi there.
15 changes: 15 additions & 0 deletions example/normal_haml/app.rb
@@ -0,0 +1,15 @@
require 'rubygems'
require 'sinatra'
require 'haml'
require 'sass'

set :haml, { :format => :html5 }

get '/' do
haml :index
end

get '/styles.css' do
content_type 'text/css', :charset => 'utf-8'
sass :styles
end
Binary file added example/normal_haml/public/favicon.ico
Binary file not shown.
7 changes: 7 additions & 0 deletions example/normal_haml/views/index.haml
@@ -0,0 +1,7 @@
#index
Um, hi there.

.explanation
views/ contains haml & sass files
.explanation
public/ has all the static files (just like Rails)
6 changes: 6 additions & 0 deletions example/normal_haml/views/layout.haml
@@ -0,0 +1,6 @@
!!!
%html
%head
%title PDXRB RULES!
%link{ :rel => :stylesheet, :href => '/styles.css' }
%body= yield
7 changes: 7 additions & 0 deletions example/normal_haml/views/styles.sass
@@ -0,0 +1,7 @@
#index
:background-color #ccc
:border 1px solid #666

.explanation
:border 2px dashed #f00
:margin 10px 0
95 changes: 95 additions & 0 deletions haml/haml.md
@@ -0,0 +1,95 @@
!SLIDE smaller
# What about Haml? #

@@@ ruby

require 'rubygems'
require 'sinatra'
require 'haml'

set :haml, { :format => :html5 }

get '/' do
haml :index
end

!SLIDE
:index can either be in (by default) views/ or in-file.

!SLIDE smaller

@@@ ruby
...

get '/' do
haml :index
end

__END__

@@ layout
!!!
%html
%head
%title PDXRB RULES!
%body= yield

@@ index
#index
Um, hi there.

!SLIDE smaller
# Normal layout/template method #
## examples/normal_haml/app.rb ##
@@@ ruby

require 'rubygems'
require 'sinatra'
require 'haml'
require 'sass'

set :haml, { :format => :html5 }

get '/' do
haml :index
end

get '/styles.css' do
content_type 'text/css', :charset => 'utf-8'
sass :styles
end

!SLIDE smaller
# The Views #
## examples/normal_haml/views/* ##

!SLIDE smaller
# examples/normal_haml/views/layout.haml #
!!!
%html
%head
%title PDXRB RULES!
%link{ :rel => :stylesheet, :href => '/styles.css' }
%body= yield

!SLIDE smaller
# examples/normal_haml/views/index.haml #

#index
Um, hi there.

.explanation
views/ contains haml & sass files
.explanation
public/ has all the static files (just like Rails)

!SLIDE smaller
# examples/normal_haml/views/styles.sass #

#index
:background-color #ccc
:border 1px solid #666

.explanation
:border 2px dashed #f00
:margin 10px 0
3 changes: 2 additions & 1 deletion showoff.json
@@ -1,5 +1,6 @@
[
{ "section" : "title" },
{ "section" : "about_me" },
{ "section" : "sinatra" }
{ "section" : "sinatra" },
{ "section" : "haml" }
]
12 changes: 7 additions & 5 deletions sinatra/sinatra.md
Expand Up @@ -7,8 +7,6 @@
# Set up an app #

$ cd /tmp
$ mkdir sinazzy && cd sinazzy
$ touch app.rb
$ vim app.rb

!SLIDE smaller
Expand All @@ -21,6 +19,9 @@
'oh you did NOT just make a little website??!!!?!!'
end

!SLIDE commandline

$ ruby app.rb


!SLIDE smaller code
Expand Down Expand Up @@ -51,7 +52,7 @@
end

!SLIDE smaller commandline incremental
# ruby example/sinazzy.rb #
# ruby examples/sinazzy.rb #
$ curl localhost:4567/
Hello World!
$ curl -X DELETE localhost:4567/
Expand Down Expand Up @@ -101,13 +102,14 @@
$ curl localhost:4567/i/dislike/puppies
I dislike puppies too!

!SLIDE
!SLIDE smaller
# You like regular expressions, right? #

@@@ ruby

get %r{/I/am/([\d]+)/years/old} do |age|
puts age # write to the logger. sometimes helpful.
puts age
# write to the logger. sometimes helpful.
end


0 comments on commit 22e2efd

Please sign in to comment.