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
81
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
40
Knowing mina deploy
lucianosousa
1
54
Creating your startup without Developer
lucianosousa
0
150
Patterns Falacy v2
lucianosousa
0
110
Project Management like Software Developer
lucianosousa
1
96
The Patterns Falacy - Rails Version
lucianosousa
1
91
Other Decks in Programming
See All in Programming
PostmanでAPIの動作確認が楽になった話
h455h1
0
180
Anthropic Cookbook のおすすめレシピ
schroneko
7
1.1k
Three ways to use AI on Android: The Good, the Bad and the Ugly
marxallski
0
110
TCAとKMPを用いた新規動画配信アプリ 「ABEMA Live」の設計
tomu28
2
130
Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform (mDevCamp 2024)
zsmb
0
430
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
380
Elm 0.19.0 Changes
bkuhlmann
0
510
Node.js v22 で変わること
yosuke_furukawa
PRO
11
3.9k
Goのmultiple errorsについて (2024年4月版)
syumai
4
1.2k
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
220
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
870
Netty Chicago Java User Group 2024-04-17
sullis
0
200
Featured
See All Featured
Optimizing for Happiness
mojombo
370
69k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
The Cost Of JavaScript in 2023
addyosmani
21
3.9k
Designing Experiences People Love
moore
136
23k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
20
1.8k
Designing the Hi-DPI Web
ddemaree
276
33k
KATA
mclloyd
16
12k
Visualization
eitanlees
137
14k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.7k
Fireside Chat
paigeccino
22
2.6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
21
1.4k
What's in a price? How to price your products and services
michaelherold
238
11k
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