Fixed some more errors.

This commit is contained in:
Kashyap 2013-01-10 00:39:25 +05:30
parent f12333bcd3
commit 2e9dc82a5a
1 changed files with 18 additions and 16 deletions

View File

@ -141,7 +141,7 @@ get '/foo' do
end end
``` ```
Other available conditions are +host_name+ and +provides+: Other available conditions are `host_name` and `provides`:
```ruby ```ruby
get '/', :host_name => /^admin\./ do get '/', :host_name => /^admin\./ do
@ -221,7 +221,7 @@ end
get('/') { Stream.new } get('/') { Stream.new }
``` ```
You can also use the +stream+ helper method (described below) to reduce boiler You can also use the `stream` helper method (described below) to reduce boiler
plate and embed the streaming logic in the route. plate and embed the streaming logic in the route.
### Custom Route Matchers ### Custom Route Matchers
@ -447,7 +447,7 @@ Dependency:: [liquid](http://www.liquidmarkup.org/)
File Extension:: `.liquid` File Extension:: `.liquid`
Example:: `liquid :index, :locals => { :key => 'value' }` Example:: `liquid :index, :locals => { :key => 'value' }`
Since you cannot call Ruby methods (except for +yield+) from a Liquid Since you cannot call Ruby methods (except for `yield`) from a Liquid
template, you almost always want to pass locals to it. template, you almost always want to pass locals to it.
#### Markdown Templates #### Markdown Templates
@ -468,7 +468,7 @@ engine:
erb :overview, :locals => { :text => markdown(:introduction) } erb :overview, :locals => { :text => markdown(:introduction) }
``` ```
Note that you may also call the +markdown+ method from within other templates: Note that you may also call the `markdown` method from within other templates:
```ruby ```ruby
%h1 Hello From Haml! %h1 Hello From Haml!
@ -492,7 +492,7 @@ therefore will usually use it in combination with another rendering engine:
erb :overview, :locals => { :text => textile(:introduction) } erb :overview, :locals => { :text => textile(:introduction) }
``` ```
Note that you may also call the +textile+ method from within other templates: Note that you may also call the `textile` method from within other templates:
```ruby ```ruby
%h1 Hello From Haml! %h1 Hello From Haml!
@ -516,7 +516,7 @@ therefore will usually use it in combination with another rendering engine:
erb :overview, :locals => { :text => rdoc(:introduction) } erb :overview, :locals => { :text => rdoc(:introduction) }
``` ```
Note that you may also call the +rdoc+ method from within other templates: Note that you may also call the `rdoc` method from within other templates:
```ruby ```ruby
%h1 Hello From Haml! %h1 Hello From Haml!
@ -569,7 +569,7 @@ therefore will usually use it in combination with another rendering engine:
erb :overview, :locals => { :text => creole(:introduction) } erb :overview, :locals => { :text => creole(:introduction) }
``` ```
Note that you may also call the +creole+ method from within other templates: Note that you may also call the `creole` method from within other templates:
```ruby ```ruby
%h1 Hello From Haml! %h1 Hello From Haml!
@ -614,7 +614,7 @@ File Extension:: `.wlang`
Example:: `wlang :index, :locals => { :key => 'value' }` Example:: `wlang :index, :locals => { :key => 'value' }`
Since calling ruby methods is not idiomatic in wlang, you almost always want to pass locals Since calling ruby methods is not idiomatic in wlang, you almost always want to pass locals
to it. Layouts written in wlang and +yield+ are supported, though. to it. Layouts written in wlang and `yield` are supported, though.
#### Embedded Templates #### Embedded Templates
@ -761,7 +761,7 @@ after do
end end
``` ```
Note: Unless you use the +body+ method rather than just returning a String from Note: Unless you use the `body` method rather than just returning a String from
the routes, the body will not yet be available in the after filter, since it is the routes, the body will not yet be available in the after filter, since it is
generated later on. generated later on.
@ -1133,7 +1133,7 @@ get '/foo' do
end end
``` ```
Any additional parameters are handled like arguments passed to +halt+: Any additional parameters are handled like arguments passed to `halt`:
```ruby ```ruby
redirect to('/bar'), 303 redirect to('/bar'), 303
@ -1537,7 +1537,7 @@ vulnerabilities):
disable :protection disable :protection
``` ```
To skip a single defense layer, set +protection+ to an options hash: To skip a single defense layer, set `protection` to an options hash:
```ruby ```ruby
set :protection, :except => :path_traversal set :protection, :except => :path_traversal
@ -1681,7 +1681,7 @@ not set.
## Environments ## Environments
There are three predefined +environments+: `"development"`, There are three predefined `environments`: `"development"`,
`"production"` and `"test"`. Environments can be set `"production"` and `"test"`. Environments can be set
through the `RACK_ENV` environment variable. The default value is through the `RACK_ENV` environment variable. The default value is
`"development"`. In the `"development"` environment all templates are reloaded between `"development"`. In the `"development"` environment all templates are reloaded between
@ -1795,7 +1795,7 @@ get '/hello' do
end end
``` ```
The semantics of +use+ are identical to those defined for the The semantics of `use` are identical to those defined for the
[Rack::Builder](http://rack.rubyforge.org/doc/classes/Rack/Builder.html) DSL [Rack::Builder](http://rack.rubyforge.org/doc/classes/Rack/Builder.html) DSL
(most frequently used from rackup files). For example, the `use` method (most frequently used from rackup files). For example, the `use` method
accepts multiple/variable args as well as blocks: accepts multiple/variable args as well as blocks:
@ -1809,7 +1809,7 @@ end
Rack is distributed with a variety of standard middleware for logging, Rack is distributed with a variety of standard middleware for logging,
debugging, URL routing, authentication, and session handling. Sinatra uses debugging, URL routing, authentication, and session handling. Sinatra uses
many of these components automatically based on configuration so you many of these components automatically based on configuration so you
typically don't have to +use+ them explicitly. typically don't have to `use` them explicitly.
You can find useful middleware in You can find useful middleware in
[rack](https://github.com/rack/rack/tree/master/lib/rack), [rack](https://github.com/rack/rack/tree/master/lib/rack),
@ -1882,7 +1882,7 @@ The methods available to `Sinatra::Base` subclasses are exactly the same as thos
available via the top-level DSL. Most top-level apps can be converted to available via the top-level DSL. Most top-level apps can be converted to
`Sinatra::Base` components with two modifications: `Sinatra::Base` components with two modifications:
* Your file should require `sinatra/base` instead of +sinatra+; * Your file should require `sinatra/base` instead of `sinatra`;
otherwise, all of Sinatra's DSL methods are imported into the main otherwise, all of Sinatra's DSL methods are imported into the main
namespace. namespace.
* Put your app's routes, error handlers, filters, and options in a subclass * Put your app's routes, error handlers, filters, and options in a subclass
@ -2103,7 +2103,7 @@ You have the application scope binding inside:
* Your application class body * Your application class body
* Methods defined by extensions * Methods defined by extensions
* The block passed to +helpers+ * The block passed to `helpers`
* Procs/blocks used as value for `set` * Procs/blocks used as value for `set`
* The block passed to `Sinatra.new` * The block passed to `Sinatra.new`
@ -2172,12 +2172,14 @@ ruby myapp.rb [-h] [-x] [-e ENVIRONMENT] [-p PORT] [-o HOST] [-s HANDLER]
Options are: Options are:
```
-h # help -h # help
-p # set the port (default is 4567) -p # set the port (default is 4567)
-o # set the host (default is 0.0.0.0) -o # set the host (default is 0.0.0.0)
-e # set the environment (default is development) -e # set the environment (default is development)
-s # specify rack server/handler (default is thin) -s # specify rack server/handler (default is thin)
-x # turn on the mutex lock (default is off) -x # turn on the mutex lock (default is off)
```
## Requirement ## Requirement