2013-03-04 16:25:59 +00:00
# Sinatra
2009-08-05 00:43:49 +00:00
2013-03-04 16:25:59 +00:00
*注)
本文書は英語から翻訳したものであり、その内容が最新でない場合もあります。最新の情報はオリジナルの英語版を参照して下さい。*
2009-08-05 00:43:49 +00:00
2016-01-21 16:47:45 +00:00
Sinatraは最小の労力でRubyによるWebアプリケーションを手早く作るための[DSL](https://ja.wikipedia.org/wiki/メインページドメイン固有言語)です。
2013-03-04 16:25:59 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
# myapp.rb
require 'sinatra'
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2014-01-13 13:03:03 +00:00
get '/' do
'Hello world!'
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
gemをインストールし、
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
gem install sinatra
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
次のように実行します。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ruby myapp.rb
```
2016-01-22 01:09:12 +00:00
[http://localhost:4567 ](http://localhost:4567 ) を開きます。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ThinがあればSinatraはこれを利用するので、`gem install thin`することをお薦めします。
## 目次
* [Sinatra ](#sinatra )
* [目次 ](#目次 )
* [ルーティング(Routes) ](#ルーティングroutes )
* [条件(Conditions) ](#条件conditions )
* [戻り値(Return Values) ](#戻り値return-values )
* [カスタムルーティングマッチャー(Custom Route Matchers) ](#カスタムルーティングマッチャーcustom-route-matchers )
* [静的ファイル(Static Files) ](#静的ファイルstatic-files )
* [ビュー / テンプレート(Views / Templates) ](#ビュー--テンプレートviews--templates )
* [リテラルテンプレート(Literal Templates) ](#リテラルテンプレートliteral-templates )
* [利用可能なテンプレート言語 ](#利用可能なテンプレート言語 )
* [Haml テンプレート ](#haml-テンプレート )
* [Erb テンプレート ](#erb-テンプレート )
* [Builder テンプレート ](#builder-テンプレート )
* [Nokogiri テンプレート ](#nokogiri-テンプレート )
* [Sass テンプレート ](#sass-テンプレート )
* [SCSS テンプレート ](#scss-テンプレート )
* [Less テンプレート ](#less-テンプレート )
* [Liquid テンプレート ](#liquid-テンプレート )
* [Markdown テンプレート ](#markdown-テンプレート )
* [Textile テンプレート ](#textile-テンプレート )
* [RDoc テンプレート ](#rdoc-テンプレート )
2014-02-23 02:50:57 +00:00
* [AsciiDoc テンプレート ](#asciidoc-テンプレート )
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
* [Radius テンプレート ](#radius-テンプレート )
* [Markaby テンプレート ](#markaby-テンプレート )
* [RABL テンプレート ](#rabl-テンプレート )
* [Slim テンプレート ](#slim-テンプレート )
* [Creole テンプレート ](#creole-テンプレート )
2014-03-26 04:09:45 +00:00
* [MediaWiki テンプレート ](#mediawiki-テンプレート )
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
* [CoffeeScript テンプレート ](#coffeescript-テンプレート )
* [Stylus テンプレート ](#stylus-テンプレート )
* [Yajl テンプレート ](#yajl-テンプレート )
* [WLang テンプレート ](#wlang-テンプレート )
* [テンプレート内での変数へのアクセス ](#テンプレート内での変数へのアクセス )
* [`yield`を伴うテンプレートとネストしたレイアウト ](#yieldを伴うテンプレートとネストしたレイアウト )
* [インラインテンプレート(Inline Templates) ](#インラインテンプレートinline-templates )
* [名前付きテンプレート(Named Templates) ](#名前付きテンプレートnamed-templates )
* [ファイル拡張子の関連付け ](#ファイル拡張子の関連付け )
* [オリジナルテンプレートエンジンの追加 ](#オリジナルテンプレートエンジンの追加 )
* [フィルタ(Filters) ](#フィルタfilters )
* [ヘルパー(Helpers) ](#ヘルパーhelpers )
* [セッションの使用 ](#セッションの使用 )
* [停止(Halting) ](#停止halting )
* [パッシング(Passing) ](#パッシングpassing )
* [別ルーティングの誘発 ](#別ルーティングの誘発 )
* [ボディ、ステータスコードおよびヘッダの設定 ](#ボディステータスコードおよびヘッダの設定 )
* [ストリーミングレスポンス(Streaming Responses) ](#ストリーミングレスポンスstreaming-responses )
* [ロギング(Logging) ](#ロギングlogging )
* [MIMEタイプ(Mime Types) ](#mimeタイプmime-types )
* [URLの生成 ](#urlの生成 )
* [ブラウザリダイレクト(Browser Redirect) ](#ブラウザリダイレクトbrowser-redirect )
* [キャッシュ制御(Cache Control) ](#キャッシュ制御cache-control )
* [ファイルの送信 ](#ファイルの送信 )
* [リクエストオブジェクトへのアクセス ](#リクエストオブジェクトへのアクセス )
* [アタッチメント(Attachments) ](#アタッチメントattachments )
* [日付と時刻の取り扱い ](#日付と時刻の取り扱い )
* [テンプレートファイルの探索 ](#テンプレートファイルの探索 )
* [コンフィギュレーション(Configuration) ](#コンフィギュレーションconfiguration )
* [攻撃防御に対する設定 ](#攻撃防御に対する設定 )
* [利用可能な設定 ](#利用可能な設定 )
* [環境設定(Environments) ](#環境設定environments )
* [エラーハンドリング(Error Handling) ](#エラーハンドリングerror-handling )
* [Not Found ](#not-found )
* [エラー(Error) ](#エラーerror )
* [Rackミドルウェア(Rack Middleware) ](#rackミドルウェアrack-middleware )
* [テスト(Testing) ](#テストtesting )
* [Sinatra::Base - ミドルウェア、ライブラリおよびモジュラーアプリ ](#sinatrabase---ミドルウェアライブラリおよびモジュラーアプリ )
* [モジュラースタイル vs クラッシックスタイル ](#モジュラースタイル-vs-クラッシックスタイル )
* [モジュラーアプリケーションの提供 ](#モジュラーアプリケーションの提供 )
* [config.ruを用いたクラッシックスタイルアプリケーションの使用 ](#configruを用いたクラッシックスタイルアプリケーションの使用 )
* [config.ruはいつ使うのか? ](#configruはいつ使うのか )
* [Sinatraのミドルウェアとしての利用 ](#sinatraのミドルウェアとしての利用 )
* [動的なアプリケーションの生成 ](#動的なアプリケーションの生成 )
* [スコープとバインディング(Scopes and Binding) ](#スコープとバインディングscopes-and-binding )
* [アプリケーション/クラスのスコープ ](#アプリケーションクラスのスコープ )
* [リクエスト/インスタンスのスコープ ](#リクエストインスタンスのスコープ )
* [デリゲートスコープ ](#デリゲートスコープ )
* [コマンドライン ](#コマンドライン )
2015-06-24 23:21:38 +00:00
* [マルチスレッド ](#マルチスレッド )
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
* [必要環境 ](#必要環境 )
* [最新開発版 ](#最新開発版 )
* [Bundlerを使う場合 ](#bundlerを使う場合 )
* [直接組み込む場合 ](#直接組み込む場合 )
* [グローバル環境にインストールする場合 ](#グローバル環境にインストールする場合 )
* [バージョニング(Versioning) ](#バージョニングversioning )
* [参考文献 ](#参考文献 )
## ルーティング(Routes)
Sinatraでは、ルーティングはHTTPメソッドとURLマッチングパターンがペアになっています。
ルーティングはブロックに結び付けられています。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2013-09-21 10:05:25 +00:00
get '/' do
.. 何か見せる ..
end
2009-08-05 00:43:49 +00:00
2013-09-21 10:05:25 +00:00
post '/' do
.. 何か生成する ..
end
2009-08-05 00:43:49 +00:00
2013-09-21 10:05:25 +00:00
put '/' do
.. 何か更新する ..
end
2009-08-05 00:43:49 +00:00
2013-09-21 10:05:25 +00:00
patch '/' do
.. 何か修正する ..
end
delete '/' do
.. 何か削除する ..
end
options '/' do
.. 何か満たす ..
end
link '/' do
.. 何かリンクを張る ..
end
unlink '/' do
.. 何かアンリンクする ..
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ルーティングは定義された順番にマッチします。
リクエストに最初にマッチしたルーティングが呼び出されます。
2009-08-05 00:43:49 +00:00
2016-06-28 03:25:34 +00:00
トレイリングスラッシュを付けたルートは、そうでないルートと異なったものになります。
```ruby
get '/foo' do
# Does not match "GET /foo/"
end
```
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ルーティングのパターンは名前付きパラメータを含むことができ、
2013-03-04 16:25:59 +00:00
`params` ハッシュで取得できます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2013-09-21 10:05:25 +00:00
get '/hello/:name' do
2013-09-23 04:17:24 +00:00
# "GET /hello/foo" と "GET /hello/bar" にマッチ
2014-08-06 01:25:47 +00:00
# params['name'] は 'foo' か 'bar'
"Hello #{params['name']}!"
2013-09-21 10:05:25 +00:00
end
```
2009-08-05 00:43:49 +00:00
また、ブロックパラメータで名前付きパラメータにアクセスすることもできます。
2015-09-20 16:50:57 +00:00
```ruby
2013-09-21 10:05:25 +00:00
get '/hello/:name' do |n|
2013-09-23 04:17:24 +00:00
# "GET /hello/foo" と "GET /hello/bar" にマッチ
2014-08-06 01:25:47 +00:00
# params['name'] は 'foo' か 'bar'
# n が params['name'] を保持
2013-09-21 10:05:25 +00:00
"Hello #{n}!"
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ルーティングパターンはアスタリスク(すなわちワイルドカード)を含むこともでき、
2014-08-06 01:25:47 +00:00
`params['splat']` で取得できます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2013-09-21 10:05:25 +00:00
get '/say/*/to/*' do
2013-09-23 04:17:24 +00:00
# /say/hello/to/world にマッチ
2014-08-06 01:25:47 +00:00
params['splat'] # => ["hello", "world"]
2013-09-21 10:05:25 +00:00
end
2009-08-05 00:43:49 +00:00
2013-09-21 10:05:25 +00:00
get '/download/*.*' do
2013-09-23 04:17:24 +00:00
# /download/path/to/file.xml にマッチ
2014-08-06 01:25:47 +00:00
params['splat'] # => ["path/to/file", "xml"]
2013-09-21 10:05:25 +00:00
end
```
2009-08-05 00:43:49 +00:00
2014-01-25 13:00:29 +00:00
ここで、ブロックパラメータを使うこともできます。
2011-05-17 16:09:39 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2013-09-21 10:05:25 +00:00
get '/download/*.*' do |path, ext|
[path, ext] # => ["path/to/file", "xml"]
end
```
2011-05-17 16:09:39 +00:00
2014-01-25 13:00:29 +00:00
ルーティングを正規表現にマッチさせることもできます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2015-02-05 21:15:53 +00:00
get /\A\/hello\/([\w]+)\z/ do
2014-08-06 01:25:47 +00:00
"Hello, #{params['captures'].first}!"
2013-09-21 10:05:25 +00:00
end
```
2009-08-05 00:43:49 +00:00
2014-01-25 13:00:29 +00:00
ここでも、ブロックパラメータが使えます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2013-09-21 10:05:25 +00:00
get %r{/hello/([\w]+)} do |c|
"Hello, #{c}!"
end
```
2014-01-25 13:00:29 +00:00
ルーティングパターンは、オプショナルパラメータを取ることもできます。
2013-09-21 10:05:25 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2016-01-24 11:51:18 +00:00
get '/posts/:format?' do
# "GET /posts/" と "GET /posts/json", "GET /posts/xml" の拡張子などにマッチ
2013-09-21 10:05:25 +00:00
end
```
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ところで、ディレクトリトラバーサル攻撃防御設定を無効にしないと(下記参照)、
ルーティングにマッチする前にリクエストパスが修正される可能性があります。
2010-10-14 02:59:57 +00:00
2014-02-03 12:50:56 +00:00
## 条件(Conditions)
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ルーティングにはユーザエージェントのようなさまざまな条件を含めることができます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
get '/foo', :agent => /Songbird (\d\.\d)[\d\/]*?/ do
2014-08-06 01:25:47 +00:00
"Songbirdのバージョン #{params['agent'][0]}を使ってます。"
2014-01-13 13:03:03 +00:00
end
2013-03-04 16:25:59 +00:00
2014-01-13 13:03:03 +00:00
get '/foo' do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# Songbird以外のブラウザにマッチ
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ほかに`host_name`と`provides`条件が利用可能です。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
get '/', :host_name => /^admin\./ do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
"Adminエリアです。アクセスを拒否します!"
2014-01-13 13:03:03 +00:00
end
2010-10-14 02:59:57 +00:00
2014-01-13 13:03:03 +00:00
get '/', :provides => 'html' do
haml :index
end
2010-10-14 02:59:57 +00:00
2014-01-13 13:03:03 +00:00
get '/', :provides => ['rss', 'atom', 'xml'] do
builder :feed
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
独自の条件を定義することも簡単にできます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
set(:probability) { |value| condition { rand < = value } }
2013-03-04 16:25:59 +00:00
2014-01-13 13:03:03 +00:00
get '/win_a_car', :probability => 0.1 do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
"あなたの勝ちです!"
2014-01-13 13:03:03 +00:00
end
2010-10-14 02:59:57 +00:00
2014-01-13 13:03:03 +00:00
get '/win_a_car' do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
"残念、あなたの負けです。"
2014-01-13 13:03:03 +00:00
end
```
2010-10-14 02:59:57 +00:00
2014-02-03 12:50:56 +00:00
複数の値を取る条件には、アスタリスクを使います。
2015-09-20 16:50:57 +00:00
```ruby
2014-02-03 12:50:56 +00:00
set(:auth) do |*roles| # < - ここでアスタリスクを使う
condition do
unless logged_in? & & roles.any? {|role| current_user.in_role? role }
redirect "/login/", 303
end
end
end
get "/my/account/", :auth => [:user, :admin] do
"アカウントの詳細"
end
get "/only/admin/", :auth => :admin do
"ここは管理者だけ!"
end
```
## 戻り値(Return Values)
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ルーティングブロックの戻り値は、HTTPクライアントまたはRackスタックでの次のミドルウェアに渡されるレスポンスボディを決定します。
2010-10-14 02:59:57 +00:00
これは大抵の場合、上の例のように文字列ですが、それ以外の値も使用することができます。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Rackレスポンス、Rackボディオブジェクト、HTTPステータスコードのいずれかとして妥当なオブジェクトであればどのようなオブジェクトでも返すことができます。
2010-10-14 02:59:57 +00:00
2014-03-26 04:09:45 +00:00
* 3つの要素を含む配列:
`[ステータス(Fixnum), ヘッダ(Hash), レスポンスボディ(#eachに応答する)]`
* 2つの要素を含む配列:
`[ステータス(Fixnum), レスポンスボディ(#eachに応答する)]`
* `#each` に応答するオブジェクト。通常はそのまま何も返さないが、
与えられたブロックに文字列を渡す。
* ステータスコードを表現する整数(Fixnum)
2013-03-04 16:25:59 +00:00
2014-03-26 04:09:45 +00:00
これにより、例えばストリーミングを簡単に実装することができます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
class Stream
def each
100.times { |i| yield "#{i}\n" }
end
end
2010-10-14 02:59:57 +00:00
2014-01-13 13:03:03 +00:00
get('/') { Stream.new }
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
後述する`stream`ヘルパーメソッドを使って、定型パターンを減らしつつストリーミングロジックをルーティングに埋め込むこともできます。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## カスタムルーティングマッチャー(Custom Route Matchers)
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
先述のようにSinatraはルーティングマッチャーとして、文字列パターンと正規表現を使うことをビルトインでサポートしています。しかしこれに留まらず、独自のマッチャーを簡単に定義することもできるのです。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
class AllButPattern
Match = Struct.new(:captures)
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
def initialize(except)
@except = except
@captures = Match.new([])
end
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
def match(str)
@captures unless @except === str
end
end
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
def all_but(pattern)
AllButPattern.new(pattern)
end
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get all_but("/index") do
# ...
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: この例はオーバースペックであり、以下のようにも書くことができます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get // do
pass if request.path_info == "/index"
# ...
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
または、否定先読みを使って:
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get %r{^(?!/index$)} do
# ...
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## 静的ファイル(Static Files)
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
静的ファイルは`./public`ディレクトリから配信されます。
`:public_folder` オプションを指定することで別の場所を指定することができます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :public_folder, File.dirname(__FILE__) + '/static'
2014-01-13 13:03:03 +00:00
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: この静的ファイル用のディレクトリ名はURL中に含まれません。
例えば、`./public/css/style.css`は`http://example.com/css/style.css`でアクセスできます。
2010-10-10 11:53:43 +00:00
2014-03-26 04:09:45 +00:00
`Cache-Control` の設定をヘッダーへ追加するには`:static_cache_control`の設定(下記参照)を加えてください。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## ビュー / テンプレート(Views / Templates)
2010-10-10 11:53:43 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
各テンプレート言語はそれ自身のレンダリングメソッドを通して展開されます。それらのメソッドは単に文字列を返します。
2010-10-10 11:53:43 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
get '/' do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
erb :index
2014-01-13 13:03:03 +00:00
end
```
2010-10-10 11:53:43 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
これは、`views/index.erb`をレンダリングします。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
テンプレート名を渡す代わりに、直接そのテンプレートの中身を渡すこともできます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
code = "< %= Time.now %>"
erb code
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
2014-03-26 04:09:45 +00:00
テンプレートのレイアウトは第2引数のハッシュ形式のオプションをもとに表示されます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
erb :index, :layout => :post
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
2014-03-26 04:09:45 +00:00
これは、`views/post.erb`内に埋め込まれた`views/index.erb`をレンダリングします(デフォルトは`views/layout.erb`があればそれになります)。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Sinatraが理解できないオプションは、テンプレートエンジンに渡されることになります。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
haml :index, :format => :html5
2014-01-13 13:03:03 +00:00
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
テンプレート言語ごとにオプションをセットすることもできます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :haml, :format => :html5
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
haml :index
2014-01-13 13:03:03 +00:00
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
レンダリングメソッドに渡されたオプションは`set`で設定されたオプションを上書きします。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
利用可能なオプション:
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dl >
< dt > locals< / dt >
< dd >
ドキュメントに渡されるローカルのリスト。パーシャルに便利。
例: < tt > erb "< %= foo %>", :locals => {:foo => "bar"}< / tt >
< / dd >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > default_encoding< / dt >
< dd >
文字エンコーディング(不確かな場合に使用される)。デフォルトは、< tt > settings.default_encoding< / tt > 。
< / dd >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > views< / dt >
< dd >
テンプレートを読み出すビューのディレクトリ。デフォルトは、< tt > settings.views< / tt > 。
< / dd >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > layout< / dt >
< dd >
レイアウトを使うかの指定(< tt > true< / tt > または < tt > false< / tt > )。値がシンボルの場合は、使用するテンプレートが指定される。例: < tt > erb :index, :layout => !request.xhr?< / tt >
< / dd >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > content_type< / dt >
< dd >
テンプレートが生成するContent-Type。デフォルトはテンプレート言語ごとに異なる。
< / dd >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > scope< / dt >
< dd >
テンプレートをレンダリングするときのスコープ。デフォルトは、アプリケーションのインスタンス。これを変更した場合、インスタンス変数およびヘルパーメソッドが利用できなくなる。
< / dd >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > layout_engine< / dt >
< dd >
レイアウトをレンダリングするために使用するテンプレートエンジン。レイアウトをサポートしない言語で有用。デフォルトはテンプレートに使われるエンジン。例: < tt > set :rdoc, :layout_engine => :erb< / tt >
< / dd >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > layout_options< / dt >
< dd >
レイアウトをレンダリングするときだけに使う特別なオプション。例:
< tt > set :rdoc, :layout_options => { :views => 'views/layouts' }< / tt >
< / dd >
< / dl >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
テンプレートは`./views`ディレクトリ下に配置されています。
他のディレクトリを使用する場合の例:
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-03-26 04:09:45 +00:00
set :views, settings.root + '/templates'
2014-01-13 13:03:03 +00:00
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
テンプレートはシンボルを使用して参照させることを覚えておいて下さい。
2014-01-25 13:00:29 +00:00
サブディレクトリでもこの場合は`:'subdir/template'`のようにします。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
レンダリングメソッドは文字列が渡されると、それをそのまま文字列として出力するので、シンボルを使ってください。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### リテラルテンプレート(Literal Templates)
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
get '/' do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
haml '%div.title Hello World'
2014-01-13 13:03:03 +00:00
end
```
2013-03-04 16:25:59 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
これはそのテンプレート文字列をレンダリングします。
### 利用可能なテンプレート言語
いくつかの言語には複数の実装があります。使用する( そしてスレッドセーフにする) 実装を指定するには、それを最初にrequireしてください。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
require 'rdiscount' # または require 'bluecloth'
get('/') { markdown :index }
```
#### Haml テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "http://haml.info/" title = "haml" > haml< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .haml< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > haml :index, :format => :html5< / tt > < / td >
< / tr >
< / table >
#### Erb テンプレート
< table >
< tr >
< td > 依存< / td >
< td >
< a href = "http://www.kuwata-lab.com/erubis/" title = "erubis" > erubis< / a >
または erb (Rubyに同梱)
< / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .erb< / tt > , < tt > .rhtml< / tt > or < tt > .erubis< / tt > (Erubisだけ)< / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > erb :index< / tt > < / td >
< / tr >
< / table >
#### Builder テンプレート
< table >
< tr >
< td > 依存< / td >
< td >
2014-09-19 14:24:03 +00:00
< a href = "https://github.com/jimweirich/builder" title = "builder" > builder< / a >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .builder< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > builder { |xml| xml.em "hi" }< / tt > < / td >
< / tr >
< / table >
インラインテンプレート用にブロックを取ることもできます(例を参照)。
#### Nokogiri テンプレート
< table >
< tr >
< td > 依存< / td >
2016-01-21 16:40:13 +00:00
< td > < a href = "http://www.nokogiri.org/" title = "nokogiri" > nokogiri< / a > < / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .nokogiri< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > nokogiri { |xml| xml.em "hi" }< / tt > < / td >
< / tr >
< / table >
インラインテンプレート用にブロックを取ることもできます(例を参照)。
#### Sass テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "http://sass-lang.com/" title = "sass" > sass< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .sass< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > sass :stylesheet, :style => :expanded< / tt > < / td >
< / tr >
< / table >
#### Scss テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "http://sass-lang.com/" title = "sass" > sass< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .scss< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > scss :stylesheet, :style => :expanded< / tt > < / td >
< / tr >
< / table >
#### Less テンプレート
< table >
< tr >
< td > 依存< / td >
2016-01-21 16:40:13 +00:00
< td > < a href = "http://lesscss.org/" title = "less" > less< / a > < / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .less< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > less :stylesheet< / tt > < / td >
< / tr >
< / table >
#### Liquid テンプレート
< table >
< tr >
< td > 依存< / td >
2016-01-21 16:40:13 +00:00
< td > < a href = "http://liquidmarkup.org/" title = "liquid" > liquid< / a > < / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .liquid< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > liquid :index, :locals => { :key => 'value' }< / tt > < / td >
< / tr >
< / table >
LiquidテンプレートからRubyのメソッド(`yield`を除く)を呼び出すことができないため、ほぼ全ての場合にlocalsを指定する必要があるでしょう。
#### Markdown テンプレート
< table >
< tr >
< td > 依存< / td >
< td >
次の何れか:
2016-01-21 16:40:13 +00:00
< a href = "https://github.com/davidfstr/rdiscount" title = "RDiscount" > RDiscount< / a > ,
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< a href = "https://github.com/vmg/redcarpet" title = "RedCarpet" > RedCarpet< / a > ,
< a href = "http://deveiate.org/projects/BlueCloth" title = "BlueCloth" > BlueCloth< / a > ,
2014-09-19 14:24:03 +00:00
< a href = "http://kramdown.gettalong.org/" title = "kramdown" > kramdown< / a > ,
< a href = "https://github.com/bhollis/maruku" title = "maruku" > maruku< / a >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .markdown< / tt > , < tt > .mkd< / tt > and < tt > .md< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > markdown :index, :layout_engine => :erb< / tt > < / td >
< / tr >
< / table >
Markdownからメソッドを呼び出すことも、localsに変数を渡すこともできません。
それゆえ、他のレンダリングエンジンとの組み合わせで使うのが普通です。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
erb :overview, :locals => { :text => markdown(:introduction) }
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: 他のテンプレート内で`markdown`メソッドを呼び出せます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
%h1 Hello From Haml!
%p= markdown(:greetings)
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
MarkdownからはRubyを呼ぶことができないので、Markdownで書かれたレイアウトを使うことはできません。しかしながら、`:layout_engine`オプションを渡すことでテンプレートのものとは異なるレンダリングエンジンをレイアウトのために使うことができます。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
#### Textile テンプレート
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< table >
< tr >
< td > 依存< / td >
< td > < a href = "http://redcloth.org/" title = "RedCloth" > RedCloth< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .textile< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > textile :index, :layout_engine => :erb< / tt > < / td >
< / tr >
< / table >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Textileからメソッドを呼び出すことも、localsに変数を渡すこともできません。
それゆえ、他のレンダリングエンジンとの組み合わせで使うのが普通です。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
erb :overview, :locals => { :text => textile(:introduction) }
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: 他のテンプレート内で`textile`メソッドを呼び出せます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
%h1 Hello From Haml!
%p= textile(:greetings)
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
TexttileからはRubyを呼ぶことができないので、Textileで書かれたレイアウトを使うことはできません。しかしながら、`:layout_engine`オプションを渡すことでテンプレートのものとは異なるレンダリングエンジンをレイアウトのために使うことができます。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
#### RDoc テンプレート
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< table >
< tr >
< td > 依存< / td >
2014-09-19 14:24:03 +00:00
< td > < a href = "http://rdoc.sourceforge.net/" title = "RDoc" > RDoc< / a > < / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .rdoc< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > rdoc :README, :layout_engine => :erb< / tt > < / td >
< / tr >
< / table >
RDocからメソッドを呼び出すことも、localsに変数を渡すこともできません。
それゆえ、他のレンダリングエンジンとの組み合わせで使うのが普通です。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
erb :overview, :locals => { :text => rdoc(:introduction) }
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: 他のテンプレート内で`rdoc`メソッドを呼び出せます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
%h1 Hello From Haml!
%p= rdoc(:greetings)
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
RDocからはRubyを呼ぶことができないので、RDocで書かれたレイアウトを使うことはできません。しかしながら、`:layout_engine`オプションを渡すことでテンプレートのものとは異なるレンダリングエンジンをレイアウトのために使うことができます。
2014-02-22 16:37:53 +00:00
#### AsciiDoc テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "http://asciidoctor.org/" title = "Asciidoctor" > Asciidoctor< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .asciidoc< / tt > , < tt > .adoc< / tt > and < tt > .ad< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > asciidoc :README, :layout_engine => :erb< / tt > < / td >
< / tr >
< / table >
AsciiDocテンプレートからRubyのメソッドを直接呼び出すことができないため、ほぼ全ての場合にlocalsを指定する必要があるでしょう。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
#### Radius テンプレート
< table >
< tr >
< td > 依存< / td >
2014-09-19 14:24:03 +00:00
< td > < a href = "https://github.com/jlong/radius" title = "Radius" > Radius< / a > < / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .radius< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > radius :index, :locals => { :key => 'value' }< / tt > < / td >
< / tr >
< / table >
RadiusテンプレートからRubyのメソッドを直接呼び出すことができないため、ほぼ全ての場合にlocalsを指定する必要があるでしょう。
#### Markaby テンプレート
< table >
< tr >
< td > 依存< / td >
2016-01-21 16:40:13 +00:00
< td > < a href = "http://markaby.github.io/" title = "Markaby" > Markaby< / a > < / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .mab< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > markaby { h1 "Welcome!" }< / tt > < / td >
< / tr >
< / table >
インラインテンプレート用にブロックを取ることもできます(例を参照)。
#### RABL テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "https://github.com/nesquena/rabl" title = "Rabl" > Rabl< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .rabl< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > rabl :index< / tt > < / td >
< / tr >
< / table >
#### Slim テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "http://slim-lang.com/" title = "Slim Lang" > Slim Lang< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .slim< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > slim :index< / tt > < / td >
< / tr >
< / table >
#### Creole テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "https://github.com/minad/creole" title = "Creole" > Creole< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .creole< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > creole :wiki, :layout_engine => :erb< / tt > < / td >
< / tr >
< / table >
Creoleからメソッドを呼び出すことも、localsに変数を渡すこともできません。
それゆえ、他のレンダリングエンジンとの組み合わせで使うのが普通です。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
erb :overview, :locals => { :text => creole(:introduction) }
```
ノート: 他のテンプレート内で`creole`メソッドを呼び出せます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
%h1 Hello From Haml!
%p= creole(:greetings)
```
CreoleからはRubyを呼ぶことができないので、Creoleで書かれたレイアウトを使うことはできません。しかしながら、`:layout_engine`オプションを渡すことでテンプレートのものとは異なるレンダリングエンジンをレイアウトのために使うことができます。
2014-03-26 04:09:45 +00:00
#### MediaWiki テンプレート
< table >
< tr >
< td > 依存< / td >
< td > < a href = "https://github.com/nricciar/wikicloth" title = "WikiCloth" > WikiCloth< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .mediawiki< / tt > および < tt > .mw< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > mediawiki :wiki, :layout_engine => :erb< / tt > < / td >
< / tr >
< / table >
MediaWikiのテンプレートは直接メソッドから呼び出したり、ローカル変数を通すことはできません。それゆえに、通常は別のレンダリングエンジンと組み合わせて利用します。
```ruby
erb :overview, :locals => { :text => mediawiki(:introduction) }
```
ノート: 他のテンプレートから部分的に`mediawiki`メソッドを呼び出すことも可能です。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
#### CoffeeScript テンプレート
< table >
< tr >
< td > 依存< / td >
< td >
< a href = "https://github.com/josh/ruby-coffee-script" title = "Ruby CoffeeScript" >
CoffeeScript
2014-02-22 16:37:53 +00:00
< / a > および
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< a href = "https://github.com/sstephenson/execjs/blob/master/README.md#readme" title = "ExecJS" >
JavaScriptの起動方法
< / a >
< / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .coffee< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > coffee :index< / tt > < / td >
< / tr >
< / table >
#### Stylus テンプレート
< table >
< tr >
< td > 依存< / td >
< td >
2016-01-21 16:40:13 +00:00
< a href = "https://github.com/forgecrafted/ruby-stylus" title = "Ruby Stylus" >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Stylus
2014-02-22 16:37:53 +00:00
< / a > および
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< a href = "https://github.com/sstephenson/execjs/blob/master/README.md#readme" title = "ExecJS" >
JavaScriptの起動方法
< / a >
< / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .styl< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > stylus :index< / tt > < / td >
< / tr >
< / table >
Stylusテンプレートを使えるようにする前に、まず`stylus`と`stylus/tilt`を読み込む必要があります。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
require 'sinatra'
require 'stylus'
require 'stylus/tilt'
2010-10-14 02:59:57 +00:00
2014-01-13 13:03:03 +00:00
get '/' do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
stylus :example
2014-01-13 13:03:03 +00:00
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
#### Yajl テンプレート
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< table >
< tr >
< td > 依存< / td >
< td > < a href = "https://github.com/brianmario/yajl-ruby" title = "yajl-ruby" > yajl-ruby< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .yajl< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td >
< tt >
yajl :index,
:locals => { :key => 'qux' },
:callback => 'present',
:variable => 'resource'
< / tt >
< / td >
< / tr >
< / table >
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
テンプレートのソースはRubyの文字列として評価され、その結果のJSON変数は`#to_json`を使って変換されます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
json = { :foo => 'bar' }
json[:baz] = key
2014-01-13 13:03:03 +00:00
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
`:callback` および`:variable`オプションは、レンダリングされたオブジェクトを装飾するために使うことができます。
2012-06-01 02:22:06 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
var resource = {"foo":"bar","baz":"qux"}; present(resource);
2014-01-13 13:03:03 +00:00
```
2012-06-01 02:22:06 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
#### WLang テンプレート
2010-11-05 12:59:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< table >
< tr >
< td > 依存< / td >
< td > < a href = "https://github.com/blambeau/wlang/" title = "wlang" > wlang< / a > < / td >
< / tr >
< tr >
< td > ファイル拡張子< / td >
< td > < tt > .wlang< / tt > < / td >
< / tr >
< tr >
< td > 例< / td >
< td > < tt > wlang :index, :locals => { :key => 'value' }< / tt > < / td >
< / tr >
< / table >
2010-11-05 12:59:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
WLang内でのRubyメソッドの呼び出しは一般的ではないので、ほとんどの場合にlocalsを指定する必要があるでしょう。しかしながら、WLangで書かれたレイアウトは`yield`をサポートしています。
2010-11-05 12:59:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### テンプレート内での変数へのアクセス
2011-04-15 09:51:35 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
テンプレートはルーティングハンドラと同じコンテキストの中で評価されます。ルーティングハンドラでセットされたインスタンス変数はテンプレート内で直接使うことができます。
2011-04-15 09:51:35 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/:id' do
2014-08-06 01:25:47 +00:00
@foo = Foo.find(params['id'])
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
haml '%h1= @foo .name'
2014-01-13 13:03:03 +00:00
end
```
2011-04-15 09:51:35 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
また、ローカル変数のハッシュで明示的に指定することもできます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/:id' do
2014-08-06 01:25:47 +00:00
foo = Foo.find(params['id'])
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
haml '%h1= bar.name', :locals => { :bar => foo }
2014-01-13 13:03:03 +00:00
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
このやり方は他のテンプレート内で部分テンプレートとして表示する時に典型的に使用されます。
### `yield`を伴うテンプレートとネストしたレイアウト
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
レイアウトは通常、`yield`を呼ぶ単なるテンプレートに過ぎません。
そのようなテンプレートは、既に説明した`:template`オプションを通して使われるか、または次のようなブロックを伴ってレンダリングされます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
erb :post, :layout => false do
erb :index
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
このコードは、`erb :index, :layout => :post`とほぼ等価です。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
レンダリングメソッドにブロックを渡すスタイルは、ネストしたレイアウトを作るために最も役立ちます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
erb :main_layout, :layout => false do
erb :admin_layout do
erb :user
end
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
これはまた次のより短いコードでも達成できます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
erb :admin_layout, :layout => :main_layout do
erb :user
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
現在、次のレンダリングメソッドがブロックを取れます: `erb` , `haml` ,
`liquid` , `slim ` , `wlang` 。
また汎用の`render`メソッドもブロックを取れます。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### インラインテンプレート(Inline Templates)
2009-08-05 00:43:49 +00:00
テンプレートはソースファイルの最後で定義することもできます。
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
require 'sinatra'
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
get '/' do
haml :index
end
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
__END__
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
@@ layout
%html
= yield
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
@@ index
%div.title Hello world!!!!!
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: Sinatraをrequireするソースファイル内で定義されたインラインテンプレートは自動的に読み込まれます。他のソースファイル内にインラインテンプレートがある場合には`enable :inline_templates`を明示的に呼んでください。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### 名前付きテンプレート(Named Templates)
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
テンプレートはトップレベルの`template`メソッドで定義することもできます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
template :layout do
"%html\n =yield\n"
end
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
template :index do
'%div.title Hello World!'
end
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
get '/' do
haml :index
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
「layout」というテンプレートが存在する場合、そのテンプレートファイルは他のテンプレートがレンダリングされる度に使用されます。`:layout => false`で個別に、または`set :haml, :layout => false`でデフォルトとして、レイアウトを無効にすることができます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
get '/' do
haml :index, :layout => !request.xhr?
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### ファイル拡張子の関連付け
任意のテンプレートエンジンにファイル拡張子を関連付ける場合は、`Tilt.register`を使います。例えば、Textileテンプレートに`tt`というファイル拡張子を使いたい場合は、以下のようにします。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Tilt.register :tt, Tilt[:textile]
```
### オリジナルテンプレートエンジンの追加
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
まず、Tiltでそのエンジンを登録し、次にレンダリングメソッドを作ります。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Tilt.register :myat, MyAwesomeTemplateEngine
2014-01-13 13:03:03 +00:00
helpers do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
def myat(*args) render(:myat, *args) end
2014-01-13 13:03:03 +00:00
end
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
myat :index
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
これは、`./views/index.myat`をレンダリングします。Tiltについての詳細は、https://github.com/rtomayko/tilt を参照してください。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## フィルタ(Filters)
beforeフィルタは、リクエストのルーティングと同じコンテキストで各リクエストの前に評価され、それによってリクエストとレスポンスを変更可能にします。フィルタ内でセットされたインスタンス変数はルーティングとテンプレートからアクセスすることができます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
before do
@note = 'Hi!'
request.path_info = '/foo/bar/baz'
end
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
get '/foo/*' do
@note #=> 'Hi!'
2014-08-06 01:25:47 +00:00
params['splat'] #=> 'bar/baz'
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
afterフィルタは、リクエストのルーティングと同じコンテキストで各リクエストの後に評価され、それによってこれもリクエストとレスポンスを変更可能にします。beforeフィルタとルーティング内でセットされたインスタンス変数はafterフィルタからアクセスすることができます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
after do
puts response.status
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: `body` メソッドを使わずにルーティングから文字列を返すだけの場合、その内容はafterフィルタでまだ利用できず、その後に生成されることになります。
フィルタにはオプションとしてパターンを渡すことができ、この場合はリクエストのパスがパターンにマッチした場合にのみフィルタが評価されるようになります。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
before '/protected/*' do
authenticate!
end
2010-10-14 02:59:57 +00:00
2014-01-13 13:03:03 +00:00
after '/create/:slug' do |slug|
session[:last_slug] = slug
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ルーティング同様、フィルタもまた条件を取ることができます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
before :agent => /Songbird/ do
# ...
end
after '/blog/*', :host_name => 'example.com' do
# ...
end
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## ヘルパー(Helpers)
トップレベルの`helpers`メソッドを使用してルーティングハンドラやテンプレートで使うヘルパーメソッドを定義できます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
helpers do
def bar(name)
"#{name}bar"
end
end
get '/:name' do
2014-08-06 01:25:47 +00:00
bar(params['name'])
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
end
2014-01-13 13:03:03 +00:00
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
あるいは、ヘルパーメソッドをモジュール内で個別に定義することもできます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
module FooUtils
def foo(name) "#{name}foo" end
end
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
module BarUtils
def bar(name) "#{name}bar" end
end
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
helpers FooUtils, BarUtils
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
その効果は、アプリケーションクラスにモジュールをインクルードするのと同じです。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### セッションの使用
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
セッションはリクエスト間での状態維持のために使用されます。その起動により、ユーザセッションごとに一つのセッションハッシュが与えられます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
enable :sessions
get '/' do
"value = " < < session [ :value ] . inspect
2014-01-13 13:03:03 +00:00
end
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/:value' do
2014-08-06 01:25:47 +00:00
session[:value] = params['value']
2014-01-13 13:03:03 +00:00
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: `enable :sessions` は実際にはすべてのデータをクッキーに保持します。これは必ずしも期待通りのものにならないかもしれません( 例えば、大量のデータを保持することでトラフィックが増大するなど) 。Rackセッションミドルウェアの利用が可能であり、その場合は`enable :sessions`を呼ばずに、選択したミドルウェアを他のミドルウェアのときと同じようにして取り込んでください。
2013-03-04 16:25:59 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
use Rack::Session::Pool, :expire_after => 2592000
2013-03-04 16:25:59 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
"value = " < < session [ :value ] . inspect
end
2013-03-04 16:25:59 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/:value' do
2014-08-06 01:25:47 +00:00
session[:value] = params['value']
2014-01-13 13:03:03 +00:00
end
```
2013-03-04 16:25:59 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
セキュリティ向上のため、クッキー内のセッションデータはセッション秘密鍵(session secret)で署名されます。Sinatraによりランダムな秘密鍵が個別に生成されます。しかし、この秘密鍵はアプリケーションの立ち上げごとに変わってしまうので、すべてのアプリケーションのインスタンスで共有できる秘密鍵をセットしたくなるかもしれません。
2013-03-04 16:25:59 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :session_secret, 'super secret'
2014-01-13 13:03:03 +00:00
```
2013-03-04 16:25:59 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
更に、設定変更をしたい場合は、`sessions`の設定においてオプションハッシュを保持することもできます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :sessions, :domain => 'foo.com'
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
foo.comのサブドメイン上のアプリ間でセッションを共有化したいときは、代わりにドメインの前に *.* を付けます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :sessions, :domain => '.foo.com'
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### 停止(Halting)
2014-03-26 04:09:45 +00:00
フィルタまたはルーティング内で直ちにリクエストを止める場合
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
halt
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
この際、ステータスを指定することもできます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
halt 410
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
body部を指定することも、
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
halt 'ここにbodyを書く'
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ステータスとbody部を指定することも、
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
halt 401, '立ち去れ!'
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ヘッダを付けることもできます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
halt 402, {'Content-Type' => 'text/plain'}, 'リベンジ'
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
もちろん、テンプレートを`halt`に結びつけることも可能です。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
halt erb(:error)
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### パッシング(Passing)
ルーティングは`pass`を使って次のルーティングに飛ばすことができます。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/guess/:who' do
2014-08-06 01:25:47 +00:00
pass unless params['who'] == 'Frank'
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
"見つかっちゃった!"
2014-01-13 13:03:03 +00:00
end
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/guess/*' do
"はずれです!"
2014-01-13 13:03:03 +00:00
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ルーティングブロックからすぐに抜け出し、次にマッチするルーティングを実行します。マッチするルーティングが見当たらない場合は404が返されます。
### 別ルーティングの誘発
`pass` を使ってルーティングを飛ばすのではなく、他のルーティングを呼んだ結果を得たいというときがあります。これを実現するには`call`を使えばいいです。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, headers, body.map(& :upcase)]
end
get '/bar' do
"bar"
2014-01-13 13:03:03 +00:00
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: 先の例において、テストを楽にしパフォーマンスを改善するには、`"bar"`を単にヘルパーに移し、`/foo`および`/bar`から使えるようにするのがいいです。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
リクエストが、その複製物でない同じアプリケーションのインスタンスに送られるようにしたいときは、`call`に代えて`call!`を使ってください。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
`call` についての詳細はRackの仕様書を参照してください。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### ボディ、ステータスコードおよびヘッダの設定
ステータスコードおよびレスポンスボディを、ルーティングブロックの戻り値にセットすることが可能であり、これは推奨されています。しかし、あるケースでは実行フローの任意のタイミングでボディをセットしたくなるかもしれません。`body`ヘルパーメソッドを使えばそれができます。そうすると、それ以降、ボディにアクセスするためにそのメソッドを使うことができるようになります。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/foo' do
body "bar"
end
after do
puts body
end
```
また、`body`にはブロックを渡すことができ、これはRackハンドラにより実行されることになります(これはストリーミングを実装するのに使われます。"戻り値"の項を参照してください。)
ボディと同様に、ステータスコードおよびヘッダもセットできます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/foo' do
status 418
headers \
"Allow" => "BREW, POST, GET, PROPFIND, WHEN",
"Refresh" => "Refresh: 20; http://www.ietf.org/rfc/rfc2324.txt"
body "I'm a tea pot!"
end
```
引数を伴わない`body`、`headers`、`status`などは、それらの現在の値にアクセスするために使えます。
### ストリーミングレスポンス(Streaming Responses)
レスポンスボディの部分を未だ生成している段階で、データを送り出したいということがあります。極端な例では、クライアントがコネクションを閉じるまでデータを送り続けたいことがあります。`stream`ヘルパーを使えば、独自ラッパーを作る必要はありません。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
stream do |out|
out << "それは伝 -\n"
sleep 0.5
out << " (少し待つ) \n"
sleep 1
out << "- 説になる!\n"
end
end
```
2016-01-21 16:40:13 +00:00
これはストリーミングAPI、[Server Sent Events](https://w3c.github.io/eventsource/)の実装を可能にし、[WebSockets](https://en.wikipedia.org/wiki/WebSocket)の土台に使うことができます。また、一部のコンテンツが遅いリソースに依存しているときに、スループットを上げるために使うこともできます。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2015-03-19 22:29:50 +00:00
ノート: ストリーミングの挙動、特に並行リクエスト(cuncurrent requests)の数は、アプリケーションを提供するのに使われるWebサーバに強く依存します。いくつかのサーバは、ストリーミングを全くサポートしません。サーバがストリーミングをサポートしない場合、ボディは`stream`に渡されたブロックの実行が終了した後、一度に全部送られることになります。ストリーミングは、Shotgunを使った場合は全く動作しません。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
オプション引数が`keep_open`にセットされている場合、ストリームオブジェクト上で`close`は呼ばれず、実行フローの任意の遅れたタイミングでユーザがこれを閉じることを可能にします。これはThinやRainbowsのようなイベント型サーバ上でしか機能しません。他のサーバでは依然ストリームは閉じられます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# ロングポーリング
set :server, :thin
connections = []
get '/subscribe' do
# サーバイベントにおけるクライアントの関心を登録
2014-11-15 17:42:37 +00:00
stream(:keep_open) do |out|
connections < < out
# 死んでいるコネクションを排除
connections.reject!(& :closed?)
end
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
end
post '/message' do
connections.each do |out|
# クライアントへ新規メッセージ到着の通知
2014-08-06 01:25:47 +00:00
out < < params [' message '] << " \n"
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# クライアントへの再接続の指示
out.close
end
# 肯定応答
"message received"
end
```
2016-06-28 03:25:34 +00:00
クライアントはソケットに書き込もうとしている接続を閉じることも可能です。そのため、記述しようとする前に`out.closed?`をチェックすることを勧めます。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### ロギング(Logging)
リクエストスコープにおいて、`logger`ヘルパーは`Logger`インスタンスを作り出します。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
logger.info "loading data"
# ...
end
```
このロガーは、自動でRackハンドラのロギング設定を参照します。ロギングが無効(disabled)にされている場合、このメソッドはダミーオブジェクトを返すので、ルーティングやフィルタにおいて特に心配することはありません。
ノート: ロギングは、`Sinatra::Application`に対してのみデフォルトで有効にされているので、`Sinatra::Base`を継承している場合は、ユーザがこれを有効化する必要があります。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
class MyApp < Sinatra::Base
configure :production, :development do
enable :logging
end
end
```
ロギングミドルウェアが設定されてしまうのを避けるには、`logging`設定を`nil`にセットします。しかしこの場合、`logger`が`nil`を返すことを忘れないように。よくあるユースケースは、オリジナルのロガーをセットしたいときです。Sinatraは、とにかく`env['rack.logger']`で見つかるものを使います。
### MIMEタイプ(Mime Types)
`send_file` か静的ファイルを使う時、SinatraがMIMEタイプを理解できない場合があります。その時は `mime_type` を使ってファイル拡張子毎に登録して下さい。
2015-09-20 16:50:57 +00:00
```ruby
2014-03-26 04:09:45 +00:00
configure do
mime_type :foo, 'text/foo'
end
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
```
これは`content_type`ヘルパーで利用することができます:
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
content_type :foo
"foo foo foo"
end
```
### URLの生成
URLを生成するためには`url`ヘルパーメソッドが使えます。Hamlではこのようにします。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
%a{:href => url('/foo')} foo
```
これはリバースプロキシおよびRackルーティングを、それらがあれば考慮に入れます。
このメソッドには`to`というエイリアスがあります(以下の例を参照)。
### ブラウザリダイレクト(Browser Redirect)
`redirect` ヘルパーメソッドを使うことで、ブラウザをリダイレクトさせることができます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/foo' do
redirect to('/bar')
end
```
他に追加されるパラメータは、`halt`に渡される引数と同様に取り扱われます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
redirect to('/bar'), 303
2016-01-21 16:40:13 +00:00
redirect 'http://www.google.com/', 'wrong place, buddy'
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
```
また、`redirect back`を使えば、簡単にユーザが来たページへ戻るリダイレクトを作れます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/foo' do
"< a href = '/bar' > do something< / a > "
end
get '/bar' do
do_something
redirect back
end
```
redirectに引数を渡すには、それをクエリーに追加するか、
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
redirect to('/bar?sum=42')
```
または、セッションを使います。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
enable :sessions
get '/foo' do
session[:secret] = 'foo'
redirect to('/bar')
end
get '/bar' do
session[:secret]
end
```
### キャッシュ制御(Cache Control)
ヘッダを正しく設定することが、適切なHTTPキャッシングのための基礎となります。
キャッシュ制御ヘッダ(Cache-Control header)は、次のように簡単に設定できます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
cache_control :public
"キャッシュしました!"
end
```
ヒント: キャッシングをbeforeフィルタ内で設定します。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
before do
cache_control :public, :must_revalidate, :max_age => 60
end
```
`expires` ヘルパーを対応するヘッダに使っている場合は、キャッシュ制御は自動で設定されます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
before do
expires 500, :public, :must_revalidate
end
```
キャッシュを適切に使うために、`etag`または`last_modified`を使うことを検討してください。これらのヘルパーを、重い仕事をさせる *前* に呼ぶことを推奨します。そうすれば、クライアントが既にキャッシュに最新版を持っている場合はレスポンスを直ちに破棄するようになります。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/article/:id' do
2014-08-06 01:25:47 +00:00
@article = Article.find params['id']
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
last_modified @article .updated_at
etag @article .sha1
erb :article
end
```
2016-01-21 16:40:13 +00:00
また、[weak ETag](https://ja.wikipedia.org/wiki/HTTP_ETag#Strong_and_weak_validation)を使うこともできます。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
etag @article .sha1, :weak
```
2014-09-05 19:50:35 +00:00
これらのヘルパーは、キャッシングをしてくれませんが、必要な情報をキャッシュに与えてくれます。もし手早いリバースプロキシキャッシングの解決策をお探しなら、 [rack-cache ](https://github.com/rtomayko/rack-cache )を試してください。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
require "rack/cache"
require "sinatra"
use Rack::Cache
get '/' do
cache_control :public, :max_age => 36000
sleep 5
"hello"
end
```
`:static_cache_control` 設定(以下を参照)を、キャッシュ制御ヘッダ情報を静的ファイルに追加するために使ってください。
RFC 2616によれば、アプリケーションは、If-MatchまたはIf-None-Matchヘッダが`*`に設定されている場合には、要求されたリソースが既に存在するか否かに応じて、異なる振る舞いをすべきとなっています。Sinatraは、getのような安全なリクエストおよびputのような冪等なリクエストは既に存在しているものとして仮定し、一方で、他のリソース(例えば、postリクエスト)は新たなリソースとして取り扱われるよう仮定します。この振る舞いは、`:new_resource`オプションを渡すことで変更できます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/create' do
etag '', :new_resource => true
Article.create
erb :new_article
end
```
ここでもWeak ETagを使いたい場合は、`:kind`オプションを渡してください。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
etag '', :new_resource => true, :kind => :weak
```
### ファイルの送信
ファイルを送信するには、`send_file`ヘルパーメソッドを使います。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
send_file 'foo.png'
end
```
これはオプションを取ることもできます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
send_file 'foo.png', :type => :jpg
```
オプション一覧
< dl >
< dt > filename< / dt >
< dd > ファイル名。デフォルトは実際のファイル名。< / dd >
< dt > last_modified< / dt >
< dd > Last-Modifiedヘッダの値。デフォルトはファイルのmtime。< / dd >
< dt > type< / dt >
< dd > コンテンツの種類。設定がない場合、ファイル拡張子から類推される。< / dd >
2014-04-13 13:54:29 +00:00
< dt > disposition< / dt >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dd >
Content-Dispositionに使われる。許容値: < tt > nil< / tt > (デフォルト)、
< tt > :attachment< / tt > および < tt > :inline< / tt >
< / dd >
< dt > length< / dt >
< dd > Content-Lengthヘッダ。デフォルトはファイルサイズ。< / dd >
< dt > status< / dt >
< dd >
送られるステータスコード。静的ファイルをエラーページとして送るときに便利。
2014-02-22 16:37:53 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Rackハンドラでサポートされている場合は、Rubyプロセスからのストリーミング以外の手段が使われる。このヘルパーメソッドを使うと、Sinatraは自動で範囲リクエスト(range requests)を扱う。
< / dd >
< / dl >
2014-05-08 08:24:55 +00:00
### リクエストオブジェクトへのアクセス
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
受信するリクエストオブジェクトは、`request`メソッドを通じてリクエストレベル(フィルタ、ルーティング、エラーハンドラ)からアクセスすることができます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# アプリケーションが http://example.com/example で動作している場合
get '/foo' do
t = %w[text/css text/html application/javascript]
request.accept # ['text/html', '*/*']
request.accept? 'text/xml' # true
request.preferred_type(t) # 'text/html'
request.body # クライアントによって送信されたリクエストボディ(下記参照)
request.scheme # "http"
request.script_name # "/example"
request.path_info # "/foo"
request.port # 80
request.request_method # "GET"
request.query_string # ""
request.content_length # request.bodyの長さ
request.media_type # request.bodyのメディアタイプ
request.host # "example.com"
request.get? # true (他の動詞にも同種メソッドあり)
request.form_data? # false
request["some_param"] # some_param変数の値。[]はパラメータハッシュのショートカット
request.referrer # クライアントのリファラまたは'/'
request.user_agent # ユーザエージェント (:agent 条件によって使用される)
request.cookies # ブラウザクッキーのハッシュ
request.xhr? # Ajaxリクエストかどうか
request.url # "http://example.com/example/foo"
request.path # "/example/foo"
request.ip # クライアントのIPアドレス
request.secure? # false (sslではtrueになる)
request.forwarded? # true (リバースプロキシの裏で動いている場合)
request.env # Rackによって渡された生のenvハッシュ
end
```
`script_name` や`path_info`などのオプションは次のように利用することもできます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
before { request.path_info = "/" }
get "/" do
"全てのリクエストはここに来る"
end
```
2014-03-30 00:14:06 +00:00
`request.body` はIOまたはStringIOのオブジェクトです。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
post "/api" do
request.body.rewind # 既に読まれているときのため
data = JSON.parse request.body.read
"Hello #{data['name']}!"
end
```
### アタッチメント(Attachments)
`attachment` ヘルパーを使って、レスポンスがブラウザに表示されるのではなく、ディスクに保存されることをブラウザに対し通知することができます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
attachment
"保存しました!"
end
```
ファイル名を渡すこともできます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
attachment "info.txt"
"保存しました!"
end
```
### 日付と時刻の取り扱い
Sinatraは`time_for`ヘルパーメソッドを提供しており、それは与えられた値からTimeオブジェクトを生成します。これはまた`DateTime`、`Date`および類似のクラスを変換できます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
pass if Time.now > time_for('Dec 23, 2012')
"まだ時間がある"
end
```
このメソッドは、`expires`、`last_modified`といった種類のものの内部で使われています。そのため、アプリケーションにおいて、`time_for`をオーバーライドすることでそれらのメソッドの挙動を簡単に拡張できます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
helpers do
def time_for(value)
case value
when :yesterday then Time.now - 24*60*60
when :tomorrow then Time.now + 24*60*60
else super
end
end
end
get '/' do
last_modified :yesterday
expires :tomorrow
"hello"
end
```
### テンプレートファイルの探索
`find_template` ヘルパーは、レンダリングのためのテンプレートファイルを見つけるために使われます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
find_template settings.views, 'foo', Tilt[:haml] do |file|
puts "could be #{file}"
end
```
この例はあまり有益ではありません。しかし、このメソッドを、独自の探索機構で働くようオーバーライドするなら有益になります。例えば、複数のビューディレクトリを使えるようにしたいときがあります。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :views, ['views', 'templates']
helpers do
def find_template(views, name, engine, & block)
Array(views).each { |v| super(v, name, engine, & block) }
end
end
```
他の例としては、異なるエンジン用の異なるディレクトリを使う場合です。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :views, :sass => 'views/sass', :haml => 'templates', :default => 'views'
helpers do
def find_template(views, name, engine, & block)
_, folder = views.detect { |k,v| engine == Tilt[k] }
folder ||= views[:default]
super(folder, name, engine, & block)
end
end
```
これをエクステンションとして書いて、他の人と簡単に共有することもできます!
ノート: `find_template` はファイルが実際に存在するかのチェックをしませんが、与えられたブロックをすべての可能なパスに対し呼び出します。これがパフォーマンス上の問題にはならないのは、`render`はファイルを見つけると直ちに`break`を使うからです。また、テンプレートの場所( および内容) は、developmentモードでの起動でない限りはキャッシュされます。このことは、複雑なメソッド(a really crazy method)を書いた場合は記憶しておく必要があります。
## コンフィギュレーション(Configuration)
どの環境でも起動時に1回だけ実行されます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
configure do
# 1つのオプションをセット
set :option, 'value'
# 複数のオプションをセット
set :a => 1, :b => 2
# `set :option, true` と同じ
enable :option
# `set :option, false` と同じ
disable :option
# ブロックを使って動的な設定をすることもできます。
set(:css_dir) { File.join(views, 'css') }
end
```
環境設定(`RACK_ENV`環境変数)が`:production`に設定されている時だけ実行する方法:
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
configure :production do
...
end
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
環境設定が`:production`か`:test`に設定されている時だけ実行する方法:
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
configure :production, :test do
...
end
```
設定したオプションには`settings`からアクセスできます:
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
configure do
set :foo, 'bar'
end
get '/' do
settings.foo? # => true
settings.foo # => 'bar'
...
end
```
### 攻撃防御に対する設定
2016-01-21 16:40:13 +00:00
Sinatraは、[Rack::Protection](https://github.com/sinatra/rack-protection#readme)を使って、アプリケーションを多発する日和見的攻撃から守っています。この挙動は簡単に無効化できます(これはアプリケーションを大量の脆弱性攻撃に晒すことになります)。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
disable :protection
```
単一の防御層を外すためには、`protection`をオプションハッシュにセットします。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :protection, :except => :path_traversal
```
また配列を渡して、複数の防御を無効にすることもできます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
set :protection, :except => [:path_traversal, :session_hijacking]
```
デフォルトでSinatraは、`:sessions`が有効になっている場合、セッションベースの防御だけを設定します。しかし、自身でセッションを設定したい場合があります。その場合は、`:session`オプションを渡すことにより、セッションベースの防御を設定することができます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
use Rack::Session::Pool
set :protection, :session => true
```
### 利用可能な設定
< dl >
< dt > absolute_redirects< / dt >
< dd >
無効のとき、Sinatraは相対リダイレクトを許容するが、RFC 2616 (HTTP 1.1)は絶対リダイレクトのみを許容するので、これには準拠しなくなる。
< / dd >
< dd >
アプリケーションが、適切に設定されていないリバースプロキシの裏で走っている場合は有効。ノート: < tt > url< / tt > ヘルパーは、第2引数に< tt > false< / tt > を渡さない限り、依然として絶対URLを生成する。
< / dd >
< dd > デフォルトは無効。< / dd >
2014-09-05 16:33:35 +00:00
< dt > add_charset< / dt >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dd >
Mimeタイプ < tt > content_type< / tt > ヘルパーが自動的にキャラクタセット情報をここに追加する。このオプションは書き換えるのではなく、値を追加するようにすること。
2014-09-05 16:33:35 +00:00
< tt > settings.add_charset < < "application/foobar"< / tt >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / dd >
< dt > app_file< / dt >
< dd >
メインのアプリケーションファイルのパスであり、プロジェクトのルート、viewsおよびpublicフォルダを見つけるために使われる。
< / dd >
< dt > bind< / dt >
2014-04-13 13:54:29 +00:00
< dd > バインドするIPアドレス(デフォルト: `environment` がdevelopmentにセットされているときは、< tt > 0.0.0.0</ tt > < em > または</ em > < tt > localhost</ tt > )。ビルトインサーバでのみ使われる。</ dd >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< dt > default_encoding< / dt >
< dd > 不明なときに仮定されるエンコーディング(デフォルトは< tt > "utf-8"< / tt > )。< / dd >
< dt > dump_errors< / dt >
< dd > ログにおけるエラーの表示。< / dd >
< dt > environment< / dt >
< dd >
現在の環境。デフォルトは< tt > ENV['RACK_ENV']< / tt > 、それが無い場合は< tt > "development"< / tt > 。
< / dd >
< dt > logging< / dt >
< dd > ロガーの使用。< / dd >
< dt > lock< / dt >
< dd >
各リクエスト周りのロックの配置で、Rubyプロセスごとにリクエスト処理を並行して走らせるようにする。
< / dd >
< dd > アプリケーションがスレッドセーフでなければ有効。デフォルトは無効。< / dd >
< dt > method_override< / dt >
< dd >
put/deleteフォームを、それらをサポートしないブラウザで使えるように< tt > _method< / tt > のおまじないを使えるようにする。
< / dd >
< dt > port< / dt >
< dd > 待ち受けポート。ビルトインサーバのみで有効。< / dd >
< dt > prefixed_redirects< / dt >
< dd >
絶対パスが与えられていないときに、リダイレクトに< tt > request.script_name< / tt > を挿入するか否かの設定。これにより< tt > redirect '/foo'< / tt > は、< tt > redirect to('/foo')< / tt > のように振る舞う。デフォルトは無効。
< / dd >
< dt > protection< / dt >
< dd > Web攻撃防御を有効にするか否かの設定。上述の攻撃防御の項を参照。< / dd >
< dt > public_dir< / dt >
< dd > < tt > public_folder< / tt > のエイリアス。以下を参照。< / dd >
< dt > public_folder< / dt >
< dd >
publicファイルが提供されるディレクトリのパス。静的ファイルの提供が有効になっている場合にのみ使われる (以下の< tt > static< / tt > 設定を参照)。設定されていない場合、< tt > app_file< / tt > 設定から推定。
< / dd >
< dt > reload_templates< / dt >
< dd >
リクエスト間でテンプレートを再ロードするか否かの設定。developmentモードでは有効。
< / dd >
< dt > root< / dt >
< dd >
プロジェクトのルートディレクトリのパス。設定されていない場合、< tt > app_file< / tt > 設定から推定。
< / dd >
< dt > raise_errors< / dt >
< dd >
例外発生の設定(アプリケーションは止まる)。< tt > environment< / tt > が< tt > "test"< / tt > に設定されているときはデフォルトは有効。それ以外は無効。
< / dd >
< dt > run< / dt >
< dd >
有効のとき、SinatraがWebサーバの起動を取り扱う。rackupまたは他の手段を使うときは有効にしないこと。
< / dd >
< dt > running< / dt >
< dd > ビルトインサーバが稼働中か?この設定を変更しないこと!< / dd >
< dt > server< / dt >
< dd >
ビルトインサーバとして使用するサーバまたはサーバ群の指定。指定順位は優先度を表し、デフォルトはRuby実装に依存。
< / dd >
< dt > sessions< / dt >
< dd >
< tt > Rack::Session::Cookie< / tt > を使ったクッキーベースのセッションサポートの有効化。詳しくは、'セッションの使用'の項を参照のこと。
< / dd >
< dt > show_exceptions< / dt >
< dd >
例外発生時にブラウザにスタックトレースを表示する。< tt > environment< / tt > が< tt > "development"< / tt > に設定されているときは、デフォルトで有効。それ以外は無効。
< / dd >
< dd >
また、< tt > :after_handler< / tt > をセットすることができ、これにより、ブラウザにスタックトレースを表示する前に、アプリケーション固有のエラーハンドリングを起動させられる。
< / dd >
< dt > static< / dt >
< dd > Sinatraが静的ファイルの提供を取り扱うかの設定。< / dd >
< dd > その取り扱いができるサーバを使う場合は無効。< / dd >
< dd > 無効化でパフォーマンスは改善する< / dd >
< dd >
クラッシックスタイルではデフォルトで有効。モジュラースタイルでは無効。
< / dd >
< dt > static_cache_control< / dt >
< dd >
Sinatraが静的ファイルを提供するときこれをセットして、レスポンスに< tt > Cache-Control< / tt > ヘッダを追加するようにする。< tt > cache_control< / tt > ヘルパーを使うこと。デフォルトは無効。
< / dd >
< dd >
複数の値をセットするときは明示的に配列を使う:
< tt > set :static_cache_control, [:public, :max_age => 300]< / tt >
< / dd >
< dt > threaded< / dt >
< dd >
< tt > true< / tt > に設定されているときは、Thinにリクエストを処理するために< tt > EventMachine.defer< / tt > を使うことを通知する。
< / dd >
< dt > views< / dt >
< dd >
ビューディレクトリのパス。設定されていない場合、< tt > app_file< / tt > 設定から推定する。
< / dd >
< dt > x_cascade< / dt >
< dd >
マッチするルーティングが無い場合に、X-Cascadeヘッダをセットするか否かの設定。デフォルトは< tt > true< / tt > 。
< / dd >
< / dl >
## 環境設定(Environments)
3種類の既定環境、`"development"`、`"production"`および`"test"`があります。環境は、`RACK_ENV`環境変数を通して設定できます。デフォルト値は、`"development"`です。`"development"`環境において、すべてのテンプレートは、各リクエスト間で再ロードされ、そして、特別の`not_found`および`error`ハンドラがブラウザにスタックトレースを表示します。`"production"`および`"test"`環境においては、テンプレートはデフォルトでキャッシュされます。
異なる環境を走らせるには、`RACK_ENV`環境変数を設定します。
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
RACK_ENV=production ruby my_app.rb
```
既定メソッド、`development?`、`test?`および`production?`を、現在の環境設定を確認するために使えます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
if settings.development?
"development!"
else
"not development!"
end
end
```
## エラーハンドリング(Error Handling)
2014-01-25 13:00:29 +00:00
エラーハンドラはルーティングおよびbeforeフィルタと同じコンテキストで実行されます。すなわちこれは、`haml`、`erb`、`halt`といった便利なものが全て使えることを意味します。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2014-03-26 04:09:45 +00:00
### 未検出(Not Found)
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2014-01-25 13:00:29 +00:00
`Sinatra::NotFound` 例外が発生したとき、またはレスポンスのステータスコードが404のときに、`not_found`ハンドラが発動します。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
not_found do
'ファイルが存在しません'
end
```
### エラー(Error)
2014-01-25 13:00:29 +00:00
`error` ハンドラはルーティングブロックまたはフィルタ内で例外が発生したときはいつでも発動します。例外オブジェクトはRack変数`sinatra.error`から取得できます。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
error do
2014-08-14 08:48:02 +00:00
'エラーが発生しました。 - ' + env['sinatra.error'].message
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
end
```
エラーをカスタマイズする場合は、
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
error MyCustomError do
'エラーメッセージ...' + env['sinatra.error'].message
end
```
と書いておいて、下記のように呼び出します。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
get '/' do
raise MyCustomError, '何かがまずかったようです'
end
```
そうするとこうなります。
```
エラーメッセージ... 何かがまずかったようです
```
あるいは、ステータスコードに対応するエラーハンドラを設定することもできます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
error 403 do
'Access forbidden'
end
get '/secret' do
403
end
```
範囲指定もできます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
error 400..510 do
'Boom'
end
2014-01-13 13:03:03 +00:00
```
2010-10-14 02:59:57 +00:00
2014-01-25 13:00:29 +00:00
Sinatraを開発環境の下で実行している場合は、特別な`not_found`および`error`ハンドラが導入され、これは親切なスタックトレースと追加のデバッギング情報をブラウザに表示します。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## Rackミドルウェア(Rack Middleware)
2009-08-05 00:43:49 +00:00
2014-09-19 14:24:03 +00:00
SinatraはRuby製Webフレームワークのミニマルな標準的インタフェースである[Rack](http://rack.github.io/)上に構築されています。アプリケーションデベロッパーにとってRackにおける最も興味深い機能は、「ミドルウェア(middleware)」をサポートしていることであり、これは、サーバとアプリケーションとの間に置かれ、HTTPリクエスト/レスポンスを監視および/または操作することで、各種の汎用的機能を提供するコンポーネントです。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Sinatraはトップレベルの`use`メソッドを通して、Rackミドルウェアパイプラインの構築を楽にします。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
require 'sinatra'
require 'my_custom_middleware'
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
use Rack::Lint
use MyCustomMiddleware
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
get '/hello' do
'Hello World'
end
```
2009-08-05 00:43:49 +00:00
2016-01-21 16:40:13 +00:00
`use` の文法は、[Rack::Builder](http://www.rubydoc.info/github/rack/rack/master/Rack/Builder)DSLで定義されているそれ( rackupファイルで最もよく使われる) と同じです。例えば `use` メソッドは複数の引数、そしてブロックも取ることができます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
use Rack::Auth::Basic do |username, password|
username == 'admin' & & password == 'secret'
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Rackは、ロギング、デバッギング、URLルーティング、認証、セッション管理など、多様な標準的ミドルウェアを共に配布されています。Sinatraはその多くのコンポーネントを自動で使うよう基本設定されているため、通常、それらを`use`で明示的に指定する必要はありません。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
便利なミドルウェアを以下で見つけられます。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
[rack ](https://github.com/rack/rack/tree/master/lib/rack )、
[rack-contrib ](https://github.com/rack/rack-contrib#readm )、
または[Rack wiki](https://github.com/rack/rack/wiki/List-of-Middleware)。
## テスト(Testing)
2016-01-21 16:40:13 +00:00
SinatraでのテストはRackベースのテストライブラリまたはフレームワークを使って書くことができます。[Rack::Test](http://www.rubydoc.info/github/brynary/rack-test/master/frames)をお薦めします。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
require 'my_sinatra_app'
2015-01-10 19:30:47 +00:00
require 'minitest/autorun'
2014-01-13 13:03:03 +00:00
require 'rack/test'
2015-01-10 19:30:47 +00:00
class MyAppTest < Minitest::Test
2014-01-13 13:03:03 +00:00
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_my_default
get '/'
assert_equal 'Hello World!', last_response.body
end
def test_with_params
get '/meet', :name => 'Frank'
assert_equal 'Hello Frank!', last_response.body
end
def test_with_rack_env
get '/', {}, 'HTTP_USER_AGENT' => 'Songbird'
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
assert_equal "Songbirdを使ってます!", last_response.body
2014-01-13 13:03:03 +00:00
end
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ノート: モジュラースタイルでSinatraを使う場合は、上記`Sinatra::Application`をアプリケーションのクラス名に置き換えてください。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## Sinatra::Base - ミドルウェア、ライブラリおよびモジュラーアプリ
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
軽量なアプリケーションであれば、トップレベルでアプリケーションを定義していくことはうまくいきますが、再利用性可能なコンポーネント、例えばRackミドルウェア、RailsのMetal、サーバコンポーネントを含むシンプルなライブラリ、あるいはSinatraの拡張プログラムを構築するような場合、これは無視できない欠点を持つものとなります。トップレベルは、軽量なアプリケーションのスタイルにおける設定( 例えば、単一のアプリケーションファイル、`./public`および`./views`ディレクトリ、ロギング、例外詳細ページなど)を仮定しています。そこで`Sinatra::Base`の出番です。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
require 'sinatra/base'
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
class MyApp < Sinatra::Base
set :sessions, true
set :foo, 'bar'
2009-08-05 00:43:49 +00:00
2014-01-13 13:03:03 +00:00
get '/' do
'Hello world!'
end
end
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
`Sinatra::Base` のサブクラスで利用できるメソッドは、トップレベルDSLで利用できるものと全く同じです。ほとんどのトップレベルで記述されたアプリは、以下の2 点を修正することで`Sinatra::Base`コンポーネントに変えることができます。
* `sinatra` の代わりに`sinatra/base`を読み込む
2014-03-26 04:09:45 +00:00
(そうしない場合、SinatraのDSLメソッドの全てがmainの名前空間にインポートされます)
2014-01-25 13:00:29 +00:00
* ルーティング、エラーハンドラ、フィルタ、オプションを`Sinatra::Base`のサブクラスに書く
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2016-01-21 16:40:13 +00:00
`Sinatra::Base` はまっさらです。ビルトインサーバを含む、ほとんどのオプションがデフォルトで無効になっています。利用可能なオプションとその挙動の詳細については[Configuring Settings](http://www.sinatrarb.com/configuration.html)(英語)をご覧下さい。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
2014-04-02 14:22:00 +00:00
もしもクラシックスタイルと同じような挙動のアプリケーションをトップレベルで定義させる必要があれば、`Sinatra::Application`をサブクラス化させてください。
```ruby
require "sinatra/base"
class MyApp < Sinatra::Application
get "/" do
'Hello world!'
end
end
```
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### モジュラースタイル vs クラッシックスタイル
一般的認識と違って、クラッシックスタイルを使うことに問題はなにもありません。それがそのアプリケーションに合っているのであれば、モジュラーアプリケーションに移行する必要はありません。
モジュラースタイルを使わずにクラッシックスタイルを使った場合の一番の不利な点は、Rubyプロセスごとにただ一つのSinatraアプリケーションしか持てない点です。複数が必要な場合はモジュラースタイルに移行してください。モジュラースタイルとクラッシックスタイルを混合できないということはありません。
一方のスタイルから他方へ移行する場合、デフォルト設定がわずかに異なる点に注意が必要です。
< table >
< tr >
< th > 設定< / th >
< th > クラッシック< / th >
< th > モジュラー< / th >
2014-04-02 14:22:00 +00:00
< th > モジュラー< / th >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > app_file< / td >
< td > sinatraを読み込むファイル< / td >
< td > Sinatra::Baseをサブクラス化したファイル< / td >
2014-04-02 14:22:00 +00:00
< td > Sinatra::Applicationをサブクラス化したファイル< / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > run< / td >
< td > $0 == app_file< / td >
< td > false< / td >
2014-04-02 14:22:00 +00:00
< td > false< / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > logging< / td >
< td > true< / td >
< td > false< / td >
2014-04-02 14:22:00 +00:00
< td > true< / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > method_override< / td >
< td > true< / td >
< td > false< / td >
2014-04-02 14:22:00 +00:00
< td > true< / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > inline_templates< / td >
< td > true< / td >
< td > false< / td >
2014-04-02 14:22:00 +00:00
< td > true< / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< tr >
< td > static< / td >
< td > true< / td >
2016-01-24 12:00:19 +00:00
< td > File.exist?(public_folder)< / td >
2014-04-02 14:22:00 +00:00
< td > true< / td >
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
< / tr >
< / table >
### モジュラーアプリケーションの提供
モジュラーアプリケーションを開始、つまり`run!`を使って開始させる二種類のやり方があります。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# my_app.rb
require 'sinatra/base'
class MyApp < Sinatra::Base
# ... アプリケーションのコードを書く ...
# Rubyファイルが直接実行されたらサーバを立ち上げる
run! if app_file == $0
end
```
として、次のように起動するか、
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
ruby my_app.rb
```
または、Rackハンドラを使えるようにする`config.ru`ファイルを書いて、
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# config.ru (rackupで起動)
require './my_app'
run MyApp
```
起動します。
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
rackup -p 4567
```
### config.ruを用いたクラッシックスタイルアプリケーションの使用
アプリケーションファイルと、
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# app.rb
require 'sinatra'
get '/' do
'Hello world!'
end
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
対応する`config.ru`を書きます。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
require './app'
run Sinatra::Application
```
2013-03-04 16:25:59 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### config.ruはいつ使うのか?
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
`config.ru` ファイルは、以下の場合に適しています。
2013-03-04 16:25:59 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
* 異なるRackハンドラ(Passenger, Unicorn, Herokuなど)でデプロイしたいとき
* `Sinatra::Base` の複数のサブクラスを使いたいとき
* Sinatraをミドルウェアとして利用し、エンドポイントとしては利用しないとき
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
**モジュラースタイルに移行したという理由だけで、`config.ru`に移行する必要はなく、`config.ru`で起動するためにモジュラースタイルを使う必要はありません。**
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### Sinatraのミドルウェアとしての利用
2010-10-14 02:59:57 +00:00
Sinatraは他のRackミドルウェアを利用することができるだけでなく、
全てのSinatraアプリケーションは、それ自体ミドルウェアとして別のRackエンドポイントの前に追加することが可能です。
2013-03-04 16:25:59 +00:00
このエンドポイントには、別のSinatraアプリケーションまたは他のRackベースのアプリケーション(Rails/Ramaze/Camping/…)が用いられるでしょう。
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
require 'sinatra/base'
2013-03-04 16:25:59 +00:00
2014-01-13 13:03:03 +00:00
class LoginScreen < Sinatra::Base
enable :sessions
2013-03-04 16:25:59 +00:00
2014-01-13 13:03:03 +00:00
get('/login') { haml :login }
2013-03-04 16:25:59 +00:00
2014-01-13 13:03:03 +00:00
post('/login') do
2014-08-06 01:25:47 +00:00
if params['name'] = 'admin' and params['password'] = 'admin'
session['user_name'] = params['name']
2014-01-13 13:03:03 +00:00
else
redirect '/login'
2010-10-14 02:59:57 +00:00
end
2014-01-13 13:03:03 +00:00
end
end
2013-03-04 16:25:59 +00:00
2014-01-13 13:03:03 +00:00
class MyApp < Sinatra::Base
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# ミドルウェアはbeforeフィルタの前に実行される
2014-01-13 13:03:03 +00:00
use LoginScreen
2013-03-04 16:25:59 +00:00
2014-01-13 13:03:03 +00:00
before do
unless session['user_name']
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
halt "アクセスは拒否されました。< a href = '/login' > ログイン< / a > してください。"
2010-10-14 02:59:57 +00:00
end
2014-01-13 13:03:03 +00:00
end
get('/') { "Hello #{session['user_name']}." }
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### 動的なアプリケーションの生成
新しいアプリケーションを実行時に、定数に割り当てることなく生成したくなる場合があるでしょう。`Sinatra.new`を使えばそれができます。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
require 'sinatra/base'
my_app = Sinatra.new { get('/') { "hi" } }
my_app.run!
```
これは省略できる引数として、それが継承するアプリケーションを取ります。
```ruby
# config.ru (rackupで起動)
require 'sinatra/base'
controller = Sinatra.new do
enable :logging
helpers MyHelpers
end
map('/a') do
run Sinatra.new(controller) { get('/') { 'a' } }
end
map('/b') do
run Sinatra.new(controller) { get('/') { 'b' } }
end
```
これは特にSinatraのextensionをテストするときや、Sinatraを自身のライブラリで利用する場合に役立ちます。
これはまた、Sinatraをミドルウェアとして利用することを極めて簡単にします。
2015-09-20 16:50:57 +00:00
```ruby
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
require 'sinatra/base'
use Sinatra do
get('/') { ... }
end
run RailsProject::Application
```
## スコープとバインディング(Scopes and Binding)
2010-10-14 02:59:57 +00:00
現在のスコープはどのメソッドや変数が利用可能かを決定します。
2013-03-04 16:25:59 +00:00
### アプリケーション/クラスのスコープ
2010-10-14 02:59:57 +00:00
全てのSinatraアプリケーションはSinatra::Baseのサブクラスに相当します。
2013-03-04 16:25:59 +00:00
もしトップレベルDSLを利用しているならば(`require 'sinatra'`)このクラスはSinatra::Applicationであり、
2010-10-14 02:59:57 +00:00
そうでなければ、あなたが明示的に作成したサブクラスです。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
クラスレベルでは`get`や`before`のようなメソッドを持っています。
しかし`request`や`session`オブジェクトには、全てのリクエストに対する単一のアプリケーションクラスがあるだけなので、アクセスできません。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
`set` によって作られたオプションはクラスレベルのメソッドです。
2010-10-14 02:59:57 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
class MyApp < Sinatra::Base
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# アプリケーションスコープの中だよ!
2014-01-13 13:03:03 +00:00
set :foo, 42
foo # => 42
get '/foo' do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# もうアプリケーションスコープの中にいないよ!
2014-01-13 13:03:03 +00:00
end
end
```
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
次の場所ではアプリケーションスコープバインディングを持ちます。
2010-10-14 02:59:57 +00:00
2014-03-26 04:09:45 +00:00
* アプリケーションクラス本体
* 拡張によって定義されたメソッド
* `helpers` に渡されたブロック
* `set` の値として使われるProcまたはブロック
* `Sinatra.new` に渡されたブロック
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
このスコープオブジェクト(クラス)は次のように利用できます。
2010-10-14 02:59:57 +00:00
2014-03-26 04:09:45 +00:00
* configureブロックに渡されたオブジェクト経由(`configure { |c| ... }`)
* リクエストスコープの中での`settings`
2010-10-14 02:59:57 +00:00
2013-03-04 16:25:59 +00:00
### リクエスト/インスタンスのスコープ
2010-10-14 02:59:57 +00:00
やってくるリクエストごとに、あなたのアプリケーションクラスの新しいインスタンスが作成され、全てのハンドラブロックがそのスコープで実行されます。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
このスコープの内側からは`request`や`session`オブジェクトにアクセスすることができ、`erb`や`haml`のようなレンダリングメソッドを呼び出すことができます。
リクエストスコープの内側からは、`settings`ヘルパーによってアプリケーションスコープにアクセスすることができます。
2013-03-04 16:25:59 +00:00
2015-09-20 16:50:57 +00:00
```ruby
2014-01-13 13:03:03 +00:00
class MyApp < Sinatra::Base
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# アプリケーションスコープの中だよ!
2014-01-13 13:03:03 +00:00
get '/define_route/:name' do
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
# '/define_route/:name'のためのリクエストスコープ
2014-01-13 13:03:03 +00:00
@value = 42
2013-03-04 16:25:59 +00:00
2014-08-06 01:25:47 +00:00
settings.get("/#{params['name']}") do
# "/#{params['name']}"のためのリクエストスコープ
2014-01-13 13:03:03 +00:00
@value # => nil (not the same request)
2010-10-14 02:59:57 +00:00
end
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
"ルーティングが定義された!"
2014-01-13 13:03:03 +00:00
end
end
```
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
次の場所ではリクエストスコープバインディングを持ちます。
2010-10-14 02:59:57 +00:00
2014-03-26 04:09:45 +00:00
* get/head/post/put/delete/options/patch/link/unlink ブロック
* before/after フィルタ
* helper メソッド
* テンプレート/ビュー
2010-10-14 02:59:57 +00:00
2013-03-04 16:25:59 +00:00
### デリゲートスコープ
2010-10-14 02:59:57 +00:00
デリゲートスコープは、単にクラススコープにメソッドを転送します。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
しかしながら、クラスのバインディングを持っていないため、クラススコープと全く同じふるまいをするわけではありません。
2013-03-04 16:25:59 +00:00
委譲すると明示的に示されたメソッドのみが利用可能であり、またクラススコープと変数/状態を共有することはできません(注:
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
異なった`self`を持っています)。
2013-03-04 16:25:59 +00:00
`Sinatra::Delegator.delegate :method_name` を呼び出すことによってデリゲートするメソッドを明示的に追加することができます。
2010-10-14 02:59:57 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
次の場所ではデリゲートスコープを持ちます。
2010-10-14 02:59:57 +00:00
2014-03-26 04:09:45 +00:00
* もし`require "sinatra"`しているならば、トップレベルバインディング
* `Sinatra::Delegator` mixinでextendされたオブジェクト
2010-10-14 02:59:57 +00:00
2013-03-04 16:25:59 +00:00
コードをご覧ください: ここでは [Sinatra::Delegator
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
mixin](https://github.com/sinatra/sinatra/blob/ca06364/lib/sinatra/base.rb#L1609-1633)は[mainオブジェクトにextendされています](https://github.com/sinatra/sinatra/blob/ca06364/lib/sinatra/main.rb#L28-30)。
2013-03-04 16:25:59 +00:00
## コマンドライン
2009-08-05 00:43:49 +00:00
Sinatraアプリケーションは直接実行できます。
2015-09-20 16:50:57 +00:00
```shell
2014-01-13 13:03:03 +00:00
ruby myapp.rb [-h] [-x] [-e ENVIRONMENT] [-p PORT] [-o HOST] [-s HANDLER]
```
2009-08-05 00:43:49 +00:00
オプション:
2014-03-26 04:09:45 +00:00
```
-h # ヘルプ
-p # ポート指定(デフォルトは4567)
-o # ホスト指定(デフォルトは0.0.0.0)
-e # 環境を指定 (デフォルトはdevelopment)
-s # rackserver/handlerを指定 (デフォルトはthin)
-x # mutex lockを付ける (デフォルトはoff)
```
2009-08-05 00:43:49 +00:00
2015-06-24 23:21:38 +00:00
### マルチスレッド
_この[StackOverflow][so-answer]でのKonstantinによる回答を言い換えています。_
Sinatraでは同時実行モデルを負わせることはできませんが、根本的な部分であるThinやPuma、WebrickのようなRackハンドラ(サーバー)部分に委ねることができます。
Sinatra自身はスレッドセーフであり、もしRackハンドラが同時実行モデルのスレッドを使用していても問題はありません。
つまり、これはサーバーを起動させる時、特定のRackハンドラに対して正しい起動処理を特定することが出来ます。
この例はThinサーバーをマルチスレッドで起動する方法のデモです。
```ruby
# app.rb
require 'sinatra/base'
class App < Sinatra::Base
get '/' do
"Hello, World"
end
end
App.run!
```
サーバーを開始するコマンドです。
```
thin --threaded start
```
[so-answer]: http://stackoverflow.com/questions/6278817/is-sinatra-multi-threaded/6282999#6282999)
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## 必要環境
次のRubyバージョンが公式にサポートされています。
< dl >
< dt > Ruby 1.8.7< / dt >
< dd >
1.8.7は完全にサポートされていますが、特にそれでなければならないという理由がないのであれば、アップグレードまたはJRubyまたはRubiniusへの移行を薦めます。1.8.7のサポートがSinatra 2.0の前に終わることはないでしょう。Ruby 1.8.6はサポート対象外です。
< / dd >
< dt > Ruby 1.9.2< / dt >
< dd >
1.9.2は完全にサポートされています。1.9.2p0は、Sinatraを起動したときにセグメントフォルトを引き起こすことが分かっているので、使わないでください。公式なサポートは、少なくともSinatra 1.5のリリースまでは続きます。
< / dd >
< dt > Ruby 1.9.3< / dt >
< dd >
1.9.3は完全にサポート、そして推奨されています。以前のバージョンからの1.9.3への移行は全セッションを無効にする点、覚えておいてください。
< / dd >
< dt > Ruby 2.0.0< / dt >
< dd >
2.0.0は完全にサポート、そして推奨されています。現在、その公式サポートを終了する計画はありません。
< / dd >
< dt > Rubinius< / dt >
< dd >
Rubiniusは公式にサポートされています(Rubinius >= 2.x)。
< tt > gem install puma< / tt > することが推奨されています。
< / dd >
< dt > JRuby< / dt >
< dd >
JRubyの最新安定版が公式にサポートされています。JRubyでC拡張を使うことは推奨されていません。
< tt > gem install trinidad< / tt > することが推奨されています。
< / dd >
< / dl >
開発チームは常に最新となるRubyバージョンに注視しています。
次のRuby実装は公式にはサポートされていませんが、Sinatraが起動すると報告されています。
* JRubyとRubiniusの古いバージョン
* Ruby Enterprise Edition
* MacRuby, Maglev, IronRuby
* Ruby 1.9.0と1.9.1 (これらの使用はお薦めしません)
公式サポートをしないという意味は、問題がそこだけで起こり、サポートされているプラットフォーム上では起きない場合に、開発チームはそれはこちら側の問題ではないとみなすということです。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
開発チームはまた、ruby-head(最新となる2.1.0)に対しCIを実行していますが、それが一貫して動くようになるまで何も保証しません。2.1.0が完全にサポートされればその限りではありません。
Sinatraは、利用するRuby実装がサポートしているオペレーティングシステム上なら動作するはずです。
MacRubyを使う場合は、`gem install control_tower`してください。
Sinatraは現在、Cardinal、SmallRuby、BlueRubyまたは1.8.7以前のバージョンのRuby上では動作しません。
## 最新開発版
Sinatraの最新開発版のコードを使いたい場合は、マスターブランチに対してアプリケーションを走らせて構いません。ある程度安定しています。また、適宜プレリリース版gemをpushしているので、
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
gem install sinatra --pre
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
すれば、最新の機能のいくつかを利用できます。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### Bundlerを使う場合
2009-08-05 00:43:49 +00:00
2016-01-21 16:40:13 +00:00
最新のSinatraでアプリケーションを動作させたい場合には、[Bundler](http://bundler.io)を使うのがお薦めのやり方です。
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
まず、Bundlerがなければそれをインストールします。
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
gem install bundler
2014-01-13 13:03:03 +00:00
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
そして、プロジェクトのディレクトリで、`Gemfile`を作ります。
```ruby
source 'https://rubygems.org'
gem 'sinatra', :github => "sinatra/sinatra"
# 他の依存ライブラリ
gem 'haml' # Hamlを使う場合
gem 'activerecord', '~> 3.0' # ActiveRecord 3.xが必要かもしれません
```
ノート: `Gemfile` にアプリケーションの依存ライブラリのすべてを並べる必要があります。しかし、Sinatraが直接依存するもの(RackおよびTile)はBundlerによって自動的に取り込まれ、追加されます。
これで、以下のようにしてアプリケーションを起動することができます。
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
bundle exec ruby myapp.rb
```
### 直接組み込む場合
ローカルにクローンを作って、`sinatra/lib`ディレクトリを`$LOAD_PATH`に追加してアプリケーションを起動します。
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
cd myapp
git clone git://github.com/sinatra/sinatra.git
ruby -I sinatra/lib myapp.rb
```
追ってSinatraのソースを更新する方法。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
cd myapp/sinatra
2014-01-13 13:03:03 +00:00
git pull
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
### グローバル環境にインストールする場合
Sinatraのgemを自身でビルドすることもできます。
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
git clone git://github.com/sinatra/sinatra.git
cd sinatra
rake sinatra.gemspec
rake install
```
gemをルートとしてインストールする場合は、最後のステップはこうなります。
2009-08-05 00:43:49 +00:00
2015-09-20 16:50:57 +00:00
```shell
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
sudo rake install
```
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## バージョニング(Versioning)
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
Sinatraは、[Semantic Versioning](http://semver.org/)におけるSemVerおよびSemVerTagの両方に準拠しています。
2009-08-05 00:43:49 +00:00
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
## 参考文献
2016-01-21 16:40:13 +00:00
* [プロジェクトサイト ](http://www.sinatrarb.com/ ) - ドキュメント、ニュース、他のリソースへのリンクがあります。
* [プロジェクトに参加(貢献)する ](http://www.sinatrarb.com/contributing.html ) - バグレポート パッチの送信、サポートなど
* [Issue tracker ](https://github.com/sinatra/sinatra/issues )
* [Twitter ](https://twitter.com/sinatra )
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
* [メーリングリスト ](http://groups.google.com/group/sinatrarb/topics )
* http://freenode.net上のIRC: [#sinatra ](irc://chat.freenode.net/#sinatra )
2014-09-13 01:16:06 +00:00
* [Sinatra Book ](https://github.com/sinatra/sinatra-book/ ) クックブック、チュートリアル
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
* [Sinatra Recipes ](http://recipes.sinatrarb.com/ ) コミュニティによるレシピ集
2016-01-21 16:40:13 +00:00
* http://www.rubydoc.info/上のAPIドキュメント: [最新版(latest release)用 ](http://www.rubydoc.info/gems/sinatra )または[現在のHEAD用](http://www.rubydoc.info/github/sinatra/sinatra)
* [CIサーバ ](https://travis-ci.org/sinatra/sinatra )
update introductory section in README.jp.md
Update Route and Return values sections in README.jp.md
Add Custom Route Matchers section in README.jp.md
Update Views / Templates section in README.jp.md
Update Filters and Helpers sections in README.jp.md
Correct some wordings
Add Using Sessions section in README.jp.md
Update Halting and Passing sections in README.jp.md
Add original english titles to each section in README.jp.md
Add missing sections in original language
Add TOC and modify section titles in README.jp.md
Fix broken links in toc
Update Mime Types, Accessing the Request Object and Configuration sections in README.jp.md
Update Error Handling, Rack Middleware, and Testing, Sinatra::Base sections in README.jp.md
Update Scopes and Binding section in README.jp.md
Update Requirement, The Bleeding Edge, Versioning, and Further Reading sections in README.jp.md
Remove some original text from section titles
Update Triggering Another Route, Setting Body, Status..., Streaming Responses, and Logging sections in README.jp.md
Update Generating URLs, Browser Redirect, Cache Control, Sending Files, Attachments, Dealing with Date and Time, and Looking Up Tempalte Files in README.jp.md
Update Configuration and Environments sections in README.jp.md
Remove some original texts
Fix and Modify irrelevant lines in README.jp.md
2014-01-17 10:16:39 +00:00
* [Greenbear Laboratory Rack日本語マニュアル ](http://route477.net/w/RackReferenceJa.html )