mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Improve readme.
This commit is contained in:
parent
9567316944
commit
f8eb1197ae
1 changed files with 18 additions and 9 deletions
27
README.md
27
README.md
|
@ -12,10 +12,15 @@ get '/' do
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
Install the gem and run with:
|
Install the gem:
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
gem install sinatra
|
gem install sinatra
|
||||||
|
```
|
||||||
|
|
||||||
|
And run with:
|
||||||
|
|
||||||
|
``` shell
|
||||||
ruby myapp.rb
|
ruby myapp.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -166,6 +171,9 @@ You can also access named parameters via block parameters:
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
get '/hello/:name' do |n|
|
get '/hello/:name' do |n|
|
||||||
|
# matches "GET /hello/foo" and "GET /hello/bar"
|
||||||
|
# params[:name] is 'foo' or 'bar'
|
||||||
|
# n stores params[:name]
|
||||||
"Hello #{n}!"
|
"Hello #{n}!"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
@ -488,12 +496,13 @@ Available Options:
|
||||||
|
|
||||||
Templates are assumed to be located directly under the `./views` directory. To
|
Templates are assumed to be located directly under the `./views` directory. To
|
||||||
use a different views directory:
|
use a different views directory:
|
||||||
<tt>set :views, settings.root + '/templates'</tt>
|
`set :views, settings.root + '/templates'`
|
||||||
|
|
||||||
One important thing to remember is that you always have to reference templates
|
One important thing to remember is that you always have to reference templates
|
||||||
with symbols, even if they're in a subdirectory (in this case, use:
|
with symbols, even if they're in a subdirectory (in this case, use:
|
||||||
<tt>'subdir/template'</tt>). You must use a symbol because otherwise rendering
|
`:'subdir/template'` or `'subdir/template'.to_sym`). You must use a symbol
|
||||||
methods will render any strings passed to them directly.
|
because otherwise rendering methods will render any strings passed to them
|
||||||
|
directly.
|
||||||
|
|
||||||
### Literal Templates
|
### Literal Templates
|
||||||
|
|
||||||
|
@ -723,7 +732,6 @@ template than for the layout by passing the `:layout_engine` option.
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
It is not possible to call methods from textile, nor to pass locals to it. You
|
It is not possible to call methods from textile, nor to pass locals to it. You
|
||||||
therefore will usually use it in combination with another rendering engine:
|
therefore will usually use it in combination with another rendering engine:
|
||||||
|
|
||||||
|
@ -1033,7 +1041,7 @@ other templates.
|
||||||
### Templates with `yield` and nested layouts
|
### Templates with `yield` and nested layouts
|
||||||
|
|
||||||
A layout is usually just a template that calls `yield`.
|
A layout is usually just a template that calls `yield`.
|
||||||
Such a template can by used either through the `:template` option as
|
Such a template can be used either through the `:template` option as
|
||||||
described above, or it can be rendered with a block as follows:
|
described above, or it can be rendered with a block as follows:
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
|
@ -1993,7 +2001,7 @@ set :protection, :session => true
|
||||||
properly. Note that the <tt>url</tt> helper will still produce absolute URLs, unless you
|
properly. Note that the <tt>url</tt> helper will still produce absolute URLs, unless you
|
||||||
pass in <tt>false</tt> as the second parameter.
|
pass in <tt>false</tt> as the second parameter.
|
||||||
</dd>
|
</dd>
|
||||||
<dd>Disabled per default.</dd>
|
<dd>Disabled by default.</dd>
|
||||||
|
|
||||||
<dt>add_charsets</dt>
|
<dt>add_charsets</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
@ -2730,14 +2738,14 @@ The following Ruby versions are officially supported:
|
||||||
<dt>Rubinius</dt>
|
<dt>Rubinius</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Rubinius is officially supported (Rubinius >= 2.x). It is recommendended to
|
Rubinius is officially supported (Rubinius >= 2.x). It is recommendended to
|
||||||
`gem install puma`.
|
<tt>gem install puma</tt>.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>JRuby</dt>
|
<dt>JRuby</dt>
|
||||||
<dd>
|
<dd>
|
||||||
The latest stable release of JRuby is officially supported. It is not
|
The latest stable release of JRuby is officially supported. It is not
|
||||||
recommended to use C extensions with JRuby. It is recommended to
|
recommended to use C extensions with JRuby. It is recommended to
|
||||||
`gem install trinidad`.
|
<tt>gem install trinidad</tt>.
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
@ -2828,6 +2836,7 @@ To update the Sinatra sources in the future:
|
||||||
cd myapp/sinatra
|
cd myapp/sinatra
|
||||||
git pull
|
git pull
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Globally
|
### Install Globally
|
||||||
|
|
||||||
You can build the gem on your own:
|
You can build the gem on your own:
|
||||||
|
|
Loading…
Reference in a new issue