Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sinatra::Ftw

 Sinatra::Ftw

An introduction about Sinatra Framework

Luciano Sousa

September 18, 2010
Tweet

More Decks by Luciano Sousa

Other Decks in Programming

Transcript

  1. http://twitter.com/lucianosousa 2 Sinatra::WTF? ✔ Micro Framework web ✔ DSL ✔

    Rotas ✔ Múltiplos Templates ✔ Filtros ✔ Exemplos
  2. http://twitter.com/lucianosousa 5 Sinatra::Routes get '/' do “get in index” end

    post '/' do “post in index” end put '/' do “put in index” end delete '/' do “delete in index” end get '/:name' do “Hello #{params[:name]}!” end
  3. http://twitter.com/lucianosousa 6 Sinatra::Templates get '/' do “hello world!” end get

    '/' do erb :index end get '/' do haml :index end get '/' do erubis :index end
  4. http://twitter.com/lucianosousa 7 Sinatra::Layout get '/' do erb :index end Carrega

    arquivo arquivo layout.template dentro da pasta views automagicamente
  5. http://twitter.com/lucianosousa 12 Sinatra::Helpers helpers do def sum(value) "Result: #{value.to_i+100}" end

    end get '/:value' do sum(params[:value]) end Obs: O parâmetro :value é passado como string para o helper.