Skip to content

Commit

Permalink
sinatra example using erb added
Browse files Browse the repository at this point in the history
  • Loading branch information
crguezl committed Sep 18, 2012
1 parent de986a1 commit b4d6790
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'sinatra'
require 'haml'
require 'erb'

# before we process a route we'll set the response as plain text
# and set up an array of viable moves that a player (and the
Expand All @@ -19,22 +19,25 @@

if @player_throw == @computer_throw
@answer = "There is a tie"
haml :index
elsif @player_throw = @defeat[@computer_throw]
erb :index
elsif @player_throw == @defeat[@computer_throw]
@answer = "Computer wins; #{@computer_throw} defeats #{@player_throw}"
haml :index
erb :index
else
@answer = "Well done. #{@player_throw} beats #{@computer_throw}"
haml :index
erb :index
end
end
__END__

@@index
%html
%head
%title Rock Paper Scissors
%body
%h2 Computer chooses: #{@computer_throw}
%h2 You choose: #{@player_throw}
%h1= @answer
<html>
<head>
<title>Rock Paper Scissors</title>
</head>
<body>
<h2> Computer chooses: <%= @computer_throw %> </h2>
<h2> You choose: <%= @player_throw %> </h2>
<h1> <%= @answer %> </h1>
</body>
</html>

0 comments on commit b4d6790

Please sign in to comment.