From f8eb1197aeed15a0c146f9b6cdaeca3e9064b0b1 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Sat, 16 Mar 2013 12:09:06 -0300 Subject: [PATCH] Improve readme. --- README.md | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ce5553c3..2beef41f 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,15 @@ get '/' do end ``` -Install the gem and run with: +Install the gem: ``` shell gem install sinatra +``` + +And run with: + +``` shell ruby myapp.rb ``` @@ -166,6 +171,9 @@ You can also access named parameters via block parameters: ``` ruby 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}!" end ``` @@ -488,12 +496,13 @@ Available Options: Templates are assumed to be located directly under the `./views` directory. To use a different views directory: -set :views, settings.root + '/templates' +`set :views, settings.root + '/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: -'subdir/template'). You must use a symbol because otherwise rendering -methods will render any strings passed to them directly. +`:'subdir/template'` or `'subdir/template'.to_sym`). You must use a symbol +because otherwise rendering methods will render any strings passed to them +directly. ### Literal Templates @@ -723,7 +732,6 @@ template than for the layout by passing the `:layout_engine` option. - 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: @@ -1033,7 +1041,7 @@ other templates. ### Templates with `yield` and nested layouts 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: ``` ruby @@ -1993,7 +2001,7 @@ set :protection, :session => true properly. Note that the url helper will still produce absolute URLs, unless you pass in false as the second parameter. -
Disabled per default.
+
Disabled by default.
add_charsets
@@ -2730,14 +2738,14 @@ The following Ruby versions are officially supported:
Rubinius
Rubinius is officially supported (Rubinius >= 2.x). It is recommendended to - `gem install puma`. + gem install puma.
JRuby
The latest stable release of JRuby is officially supported. It is not recommended to use C extensions with JRuby. It is recommended to - `gem install trinidad`. + gem install trinidad.
@@ -2828,6 +2836,7 @@ To update the Sinatra sources in the future: cd myapp/sinatra git pull ``` + ### Install Globally You can build the gem on your own: