1 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
5 @items = session[:items] || []
7 %script window.document.getElementById('new_item').focus();
8 %h1 Sinatra's todo list
10 - @items.each_with_index do |item, index|
14 %form{:action => "/" + index.to_s, :method => 'POST'}
15 %input{:type => 'hidden', :name => '_method', :value => 'DELETE'}
16 %input{:type => 'submit', :value => 'delete'}
17 %form{:action => '/clear', :method => 'POST'}
18 %input{:value => 'clear', :type => :submit}
19 %form{:action => '/', :method => 'POST'}
20 %input{:type => 'textbox', :name => :new_item, :id => 'new_item'}
21 %input{:type => 'submit'}
26 (session[:items] ||= []) << params[:new_item] unless params[:new_item].to_s.strip.empty?
36 session[:items].delete_at(params[:id].to_i)