Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Sinatra::Ftw
Search
Luciano Sousa
September 18, 2010
Programming
0
86
Sinatra::Ftw
An introduction about Sinatra Framework
Luciano Sousa
September 18, 2010
Tweet
Share
More Decks by Luciano Sousa
See All by Luciano Sousa
Playing with Sorbet
lucianosousa
0
46
Knowing mina deploy
lucianosousa
1
64
Creating your startup without Developer
lucianosousa
0
160
Patterns Falacy v2
lucianosousa
0
120
Project Management like Software Developer
lucianosousa
1
100
The Patterns Falacy - Rails Version
lucianosousa
1
100
Other Decks in Programming
See All in Programming
Cursor/Devin全社導入の理想と現実
saitoryc
28
22k
Instrumentsを使用した アプリのパフォーマンス向上方法
hinakko
0
240
Thank you <💅>, What's the Next?
ahoxa
1
590
ニーリーQAのこれまでとこれから
nealle
2
470
By the way Google Cloud Next 2025に行ってみてどうだった
ymd65536
0
120
Носок на сок
bo0om
0
1.2k
KawaiiLT 登壇資料 キャリアとモチベーション
hiiragi
0
160
generative-ai-use-cases(GenU)の推しポイント ~2025年4月版~
hideg
1
380
Dissecting and Reconstructing Ruby Syntactic Structures
ydah
3
2.1k
Improve my own Ruby
sisshiki1969
0
100
AIコーディングの理想と現実
tomohisa
35
37k
実践Webフロントパフォーマンスチューニング
cp20
45
10k
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
19
1.2k
Raft: Consensus for Rubyists
vanstee
137
6.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Thoughts on Productivity
jonyablonski
69
4.6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
560
Testing 201, or: Great Expectations
jmmastey
42
7.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Adopting Sorbet at Scale
ufuk
76
9.3k
Automating Front-end Workflow
addyosmani
1370
200k
Embracing the Ebb and Flow
colly
85
4.7k
Transcript
http://twitter.com/lucianosousa 1 Sinatra::Ftw Luciano Sousa
[email protected]
http://lucianosousa.net http://twitter.com/lucianosousa http://github.com/lucianosousa
http://twitter.com/lucianosousa 2 Sinatra::WTF? ✔ Micro Framework web ✔ DSL ✔
Rotas ✔ Múltiplos Templates ✔ Filtros ✔ Exemplos
http://twitter.com/lucianosousa 3 Sinatra::Description Micro Framework para desenvolvimento de aplicações web
com o mínimo de esforço.
http://twitter.com/lucianosousa 4 Sinatra::DSL get '/hi' do “hello world!” end Domain
Specific Language
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
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
http://twitter.com/lucianosousa 7 Sinatra::Layout get '/' do erb :index end Carrega
arquivo arquivo layout.template dentro da pasta views automagicamente
http://twitter.com/lucianosousa 8
http://twitter.com/lucianosousa 9
http://twitter.com/lucianosousa 10
http://twitter.com/lucianosousa 11
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.
http://twitter.com/lucianosousa 13
http://twitter.com/lucianosousa 14 Sinatra::Filters after do puts "Response status is: #{response.status}"
end
http://twitter.com/lucianosousa 15
http://twitter.com/lucianosousa 16 Sinatra::Example