Testing out some HTML in Markdown
This commit is contained in:
parent
8d9442be52
commit
63a18c478c
343
README.md
343
README.md
|
@ -344,45 +344,65 @@ Options passed to the render method override options set via `set`.
|
|||
|
||||
Available Options:
|
||||
|
||||
**locals**
|
||||
> List of locals passed to the document. Handy with partials.
|
||||
<dl>
|
||||
<dt>locals</dt>
|
||||
<dd>
|
||||
List of locals passed to the document. Handy with partials.
|
||||
Example: `erb "<%= foo %>", :locals => {:foo => "bar"}`
|
||||
</dd>
|
||||
|
||||
**default_encoding**
|
||||
> String encoding to use if uncertain. Defaults to
|
||||
<dt>default_encoding</dt>
|
||||
<dd>
|
||||
String encoding to use if uncertain. Defaults to
|
||||
`settings.default_encoding`.
|
||||
</dd>
|
||||
|
||||
**views**
|
||||
> Views folder to load templates from. Defaults to `settings.views`.
|
||||
<dt>views</dt>
|
||||
<dd>
|
||||
Views folder to load templates from. Defaults to `settings.views`.
|
||||
</dd>
|
||||
|
||||
**layout**
|
||||
> Whether to use a layout (`true` or `false`), if it's a Symbol, specifies
|
||||
<dt>layout</dt>
|
||||
<dd>
|
||||
Whether to use a layout (`true` or `false`), if it's a Symbol, specifies
|
||||
what template to use. Example: `erb :index, :layout => !request.xhr?`
|
||||
</dd>
|
||||
|
||||
**content_type**
|
||||
> Content-Type the template produces, default depends on template language.
|
||||
<dt>content_type</dt>
|
||||
<dd>
|
||||
Content-Type the template produces, default depends on template language.
|
||||
</dd>
|
||||
|
||||
**scope**
|
||||
> Scope to render template under. Defaults to the application instance. If you
|
||||
<dt>scope</dt>
|
||||
<dd>
|
||||
Scope to render template under. Defaults to the application instance. If you
|
||||
change this, instance variables and helper methods will not be available.
|
||||
</dd>
|
||||
|
||||
**layout_engine**
|
||||
> Template engine to use for rendering the layout. Useful for languages that
|
||||
<dt>layout_engine</dt>
|
||||
<dd>
|
||||
Template engine to use for rendering the layout. Useful for languages that
|
||||
do not support layouts otherwise. Defaults to the engine used for the
|
||||
template. Example: `set :rdoc, :layout_engine => :erb`
|
||||
</dd>
|
||||
|
||||
> Templates are assumed to be located directly under the `./views`
|
||||
<dd>
|
||||
Templates are assumed to be located directly under the `./views`
|
||||
directory. To use a different views directory:
|
||||
</dd>
|
||||
|
||||
```ruby
|
||||
set :views, settings.root + '/templates'
|
||||
```
|
||||
|
||||
> One important thing to remember is that you always have to reference
|
||||
<dd>
|
||||
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.
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
### Available Template Languages
|
||||
|
||||
|
@ -396,19 +416,37 @@ get('/') { markdown :index }
|
|||
|
||||
#### Haml Templates
|
||||
|
||||
```ruby
|
||||
Dependency [haml](http://haml.info/)
|
||||
File Extension .haml
|
||||
Example haml :index, :format => :html5
|
||||
```
|
||||
<table>
|
||||
<tr>
|
||||
<td>Dependency</td>
|
||||
<td>[haml](http://haml.info/)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>File Extension</td>
|
||||
<td>.haml</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Example</td>
|
||||
<td>haml :index, :format => :html5</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
#### Erb Templates
|
||||
|
||||
```ruby
|
||||
Dependency [erubis](http://www.kuwata-lab.com/erubis/) or erb (included in Ruby)
|
||||
File Extensions .erb, .rhtml or .erubis (Erubis only)
|
||||
Example erb :index
|
||||
```
|
||||
<table>
|
||||
<tr>
|
||||
<td>Dependency</td>
|
||||
<td>[erubis](http://www.kuwata-lab.com/erubis/) or erb (included in Ruby)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>File Extensions</td>
|
||||
<td>.erb, .rhtml or .erubis (Erubis only)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Example</td>
|
||||
<td>erb :index</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
#### Builder Templates
|
||||
|
||||
|
@ -1324,28 +1362,34 @@ send_file 'foo.png', :type => :jpg
|
|||
|
||||
The options are:
|
||||
|
||||
**filename**
|
||||
> file name, in response, defaults to the real file name.
|
||||
<dl>
|
||||
<dt>filename</dt>
|
||||
<dd>file name, in response, defaults to the real file name.</dd>
|
||||
|
||||
**last_modified**
|
||||
> value for Last-Modified header, defaults to the file's mtime.
|
||||
<dt>last_modified</dt>
|
||||
<dd>value for Last-Modified header, defaults to the file's mtime.</dd>
|
||||
|
||||
**type**
|
||||
> content type to use, guessed from the file extension if missing.
|
||||
<dt>type</dt>
|
||||
<dd>content type to use, guessed from the file extension if missing.</dd>
|
||||
|
||||
**disposition**
|
||||
> used for Content-Disposition, possible values: `nil` (default),
|
||||
</dt>disposition</dt>
|
||||
<dd>
|
||||
used for Content-Disposition, possible values: `nil` (default),
|
||||
`:attachment` and `:inline`
|
||||
</dd>
|
||||
|
||||
**length**
|
||||
> Content-Length header, defaults to file size.
|
||||
<dt>length</dt>
|
||||
<dd>Content-Length header, defaults to file size.</dd>
|
||||
|
||||
**status**
|
||||
> Status code to be send. Useful when sending a static file as an error page.
|
||||
<dt>status</dt>
|
||||
<dd>
|
||||
Status code to be send. Useful when sending a static file as an error page.
|
||||
|
||||
> If supported by the Rack handler, other means than streaming from the Ruby
|
||||
If supported by the Rack handler, other means than streaming from the Ruby
|
||||
process will be used. If you use this helper method, Sinatra will automatically
|
||||
handle range requests.
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
### Accessing the Request Object
|
||||
|
||||
|
@ -1532,7 +1576,7 @@ configure do
|
|||
end
|
||||
```
|
||||
|
||||
Run only when the environment (RACK_ENV environment variable) is set to
|
||||
Run only when the environment (`RACK_ENV` environment variable) is set to
|
||||
`:production`:
|
||||
|
||||
```ruby
|
||||
|
@ -1589,134 +1633,169 @@ set :protection, :except => [:path_traversal, :session_hijacking]
|
|||
|
||||
### Available Settings
|
||||
|
||||
**absolute_redirects**
|
||||
|
||||
> If disabled, Sinatra will allow relative redirects, however, Sinatra will no
|
||||
<dl>
|
||||
<dt>absolute_redirects</dt>
|
||||
<dd>
|
||||
If disabled, Sinatra will allow relative redirects, however, Sinatra will no
|
||||
longer conform with RFC 2616 (HTTP 1.1), which only allows absolute redirects.
|
||||
|
||||
> Enable if your app is running behind a reverse proxy that has not been set up
|
||||
</dd>
|
||||
<dd>
|
||||
Enable if your app is running behind a reverse proxy that has not been set up
|
||||
properly. Note that the `url` helper will still produce absolute URLs, unless you
|
||||
pass in `false` as the second parameter.
|
||||
</dd>
|
||||
<dd>Disabled per default.</dd>
|
||||
|
||||
> Disabled per default.
|
||||
|
||||
**add_charsets**
|
||||
> mime types the `content_type` helper will automatically add the charset info to.
|
||||
<dt>add_charsets</dt>
|
||||
<dd>
|
||||
mime types the `content_type` helper will automatically add the charset info to.
|
||||
You should add to it rather than overriding this option:
|
||||
|
||||
</dd>
|
||||
```ruby
|
||||
settings.add_charsets << "application/foobar"
|
||||
```
|
||||
|
||||
**app_file**
|
||||
|
||||
> Path to the main application file, used to detect project root, views and public
|
||||
<dt>app_file</dt>
|
||||
<dd>
|
||||
Path to the main application file, used to detect project root, views and public
|
||||
folder and inline templates.
|
||||
</dt>
|
||||
|
||||
**bind**
|
||||
<dt>bind</dt>
|
||||
<dd>IP address to bind to (default: 0.0.0.0). Only used for built-in server.</dd>
|
||||
|
||||
> IP address to bind to (default: 0.0.0.0). Only used for built-in server.
|
||||
<dt>default_encoding</dt>
|
||||
<dd>encoding to assume if unknown (defaults to `"utf-8"`).</dd>
|
||||
|
||||
**default_encoding**
|
||||
<dt>dump_errors</dt>
|
||||
<dd>display errors in the log.</dd>
|
||||
|
||||
> encoding to assume if unknown (defaults to `"utf-8"`).
|
||||
|
||||
**dump_errors**
|
||||
|
||||
> display errors in the log.
|
||||
|
||||
**environment**
|
||||
|
||||
> current environment, defaults to `ENV['RACK_ENV']`, or `"development"` if
|
||||
<dt>environment</dt>
|
||||
<dd>
|
||||
current environment, defaults to `ENV['RACK_ENV']`, or `"development"` if
|
||||
not available.
|
||||
</dd>
|
||||
|
||||
**logging**
|
||||
> use the logger.
|
||||
<dt>logging</dt>
|
||||
<dd>use the logger.</dd>
|
||||
|
||||
**lock**
|
||||
> Places a lock around every request, only running processing on request
|
||||
<dt>lock</dt>
|
||||
<dd>
|
||||
Places a lock around every request, only running processing on request
|
||||
per Ruby process concurrently.
|
||||
</dd>
|
||||
<dd>Enabled if your app is not thread-safe. Disabled per default.</dd>
|
||||
|
||||
> Enabled if your app is not thread-safe. Disabled per default.
|
||||
|
||||
**method_override**
|
||||
> use `_method` magic to allow put/delete forms in browsers that
|
||||
<dt>method_override</dt>
|
||||
<dd>
|
||||
use `_method` magic to allow put/delete forms in browsers that
|
||||
don't support it.
|
||||
</dd>
|
||||
|
||||
**port**
|
||||
> Port to listen on. Only used for built-in server.
|
||||
<dt>port</dt>
|
||||
<dd>Port to listen on. Only used for built-in server.</dd>
|
||||
|
||||
**prefixed_redirects**
|
||||
> Whether or not to insert `request.script_name` into redirects if no
|
||||
<dt>prefixed_redirects</dt>
|
||||
<dd>
|
||||
Whether or not to insert `request.script_name` into redirects if no
|
||||
absolute path is given. That way `redirect '/foo'` would behave like
|
||||
`redirect to('/foo')`. Disabled per default.
|
||||
</dd>
|
||||
|
||||
**protection**
|
||||
> Whether or not to enable web attack protections. See protection section above.
|
||||
<dt>protection</dt>
|
||||
<dd>Whether or not to enable web attack protections. See protection section above.</dd>
|
||||
|
||||
**public_dir**
|
||||
> Alias for `public_folder`. See below.
|
||||
<dt>public_dir</dt>
|
||||
<dd>Alias for `public_folder`. See below.</dd>
|
||||
|
||||
**public_folder**
|
||||
> Path to the folder public files are served from. Only used if static
|
||||
<dt>public_folder</dt>
|
||||
<dd>
|
||||
Path to the folder public files are served from. Only used if static
|
||||
file serving is enabled (see `static` setting below). Inferred from
|
||||
`app_file` setting if not set.
|
||||
</dd>
|
||||
|
||||
**reload_templates**
|
||||
> Whether or not to reload templates between requests. Enabled in development mode.
|
||||
<dt>reload_templates</dt>
|
||||
<dd>
|
||||
Whether or not to reload templates between requests. Enabled in development mode.
|
||||
</dd>
|
||||
|
||||
**root**
|
||||
> Path to project root folder. Inferred from `app_file` setting if not set.
|
||||
<dt>root</dt>
|
||||
<dd>
|
||||
Path to project root folder. Inferred from `app_file` setting if not set.
|
||||
</dd>
|
||||
|
||||
**raise_errors**
|
||||
> raise exceptions (will stop application). Enabled by default when
|
||||
<dt>raise_errors</dt>
|
||||
<dd>
|
||||
raise exceptions (will stop application). Enabled by default when
|
||||
`environment` is set to `"test"`, disabled otherwise.
|
||||
</dd>
|
||||
|
||||
**run**
|
||||
> if enabled, Sinatra will handle starting the web server, do not
|
||||
<dt>run</dt>
|
||||
<dd>
|
||||
if enabled, Sinatra will handle starting the web server, do not
|
||||
enable if using rackup or other means.
|
||||
</dd>
|
||||
|
||||
**running**
|
||||
> is the built-in server running now? do not change this setting!
|
||||
<dt>running</dt>
|
||||
<dd>is the built-in server running now? do not change this setting!</dd>
|
||||
|
||||
**server**
|
||||
> server or list of servers to use for built-in server. defaults to
|
||||
<dt>server</dt>
|
||||
<dd>
|
||||
server or list of servers to use for built-in server. defaults to
|
||||
['thin', 'mongrel', 'webrick'], order indicates priority.
|
||||
</dd>
|
||||
|
||||
**sessions**
|
||||
> Enable cookie-based sessions support using `Rack::Session::Cookie`.
|
||||
<dt>sessions</dt>
|
||||
<dd>
|
||||
Enable cookie-based sessions support using `Rack::Session::Cookie`.
|
||||
See 'Using Sessions' section for more information.
|
||||
</dd>
|
||||
|
||||
**show_exceptions**
|
||||
|
||||
> Show a stack trace in the browser when an exception
|
||||
<dt>show_exceptions</dt>
|
||||
<dd>
|
||||
Show a stack trace in the browser when an exception
|
||||
happens. Enabled by default when `environment`
|
||||
is set to `"development"`, disabled otherwise.
|
||||
|
||||
> Can also be set to `:after_handler` to trigger
|
||||
</dd>
|
||||
<dd>
|
||||
Can also be set to `:after_handler` to trigger
|
||||
app-specified error handling before showing a stack
|
||||
trace in the browser.
|
||||
</dd>
|
||||
|
||||
**static**
|
||||
|
||||
> Whether Sinatra should handle serving static files.
|
||||
> Disable when using a server able to do this on its own.
|
||||
> Disabling will boost performance.
|
||||
> Enabled per default in classic style, disabled for
|
||||
<dt>static</dt>
|
||||
<dd>Whether Sinatra should handle serving static files.</dd>
|
||||
<dd>Disable when using a server able to do this on its own.</dd>
|
||||
<dd>Disabling will boost performance.</dd>
|
||||
<dd>
|
||||
Enabled per default in classic style, disabled for
|
||||
modular apps.
|
||||
</dd>
|
||||
|
||||
**static_cache_control**
|
||||
> When Sinatra is serving static files, set this to add
|
||||
<dt>static_cache_control</dt>
|
||||
<dd>
|
||||
When Sinatra is serving static files, set this to add
|
||||
`Cache-Control` headers to the responses. Uses the
|
||||
`cache_control` helper. Disabled by default.
|
||||
</dd>
|
||||
<dd>
|
||||
Use an explicit array when setting multiple values:
|
||||
`set :static_cache_control, [:public, :max_age => 300]`
|
||||
</dd>
|
||||
|
||||
**threaded**
|
||||
> If set to `true`, will tell Thin to use `EventMachine.defer`
|
||||
<dt>threaded</dt>
|
||||
<dd>
|
||||
If set to `true`, will tell Thin to use `EventMachine.defer`
|
||||
for processing the request.
|
||||
</dd>
|
||||
|
||||
**views**
|
||||
> Path to the views folder. Inferred from `app_file` setting if
|
||||
<dt>views**</dt>
|
||||
<dd>
|
||||
Path to the views folder. Inferred from `app_file` setting if
|
||||
not set.
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
## Environments
|
||||
|
||||
|
@ -2223,39 +2302,49 @@ Options are:
|
|||
## Requirement
|
||||
|
||||
The following Ruby versions are officially supported:
|
||||
|
||||
**Ruby 1.8.7**
|
||||
> 1.8.7 is fully supported, however, if nothing is keeping you from it, we
|
||||
<dl>
|
||||
<dt>Ruby 1.8.7</dt>
|
||||
<dd>
|
||||
1.8.7 is fully supported, however, if nothing is keeping you from it, we
|
||||
recommend upgrading to 1.9.2 or switching to JRuby or Rubinius. Support for
|
||||
1.8.7 will not be dropped before Sinatra 2.0 and Ruby 2.0 except maybe in
|
||||
the unlikely event of 1.8.8 being released. Even then, we might continue
|
||||
supporting it. <b>Ruby 1.8.6 is no longer supported.</b> If you want to run
|
||||
with 1.8.6, downgrade to Sinatra 1.2, which will receive bug fixes until
|
||||
Sinatra 1.4.0 is released.
|
||||
</dd>
|
||||
|
||||
**Ruby 1.9.2**
|
||||
> 1.9.2 is fully supported and recommended. Do not use 1.9.2p0, as it is known to
|
||||
<dt>Ruby 1.9.2</dt>
|
||||
<dd>
|
||||
1.9.2 is fully supported and recommended. Do not use 1.9.2p0, as it is known to
|
||||
cause segmentation faults when running Sinatra. Support will continue at least
|
||||
until the release of Ruby 1.9.4/2.0 and support for the latest 1.9 release
|
||||
will continue as long as it is still supported by the Ruby core team.
|
||||
</dd>
|
||||
|
||||
**Ruby 1.9.3**
|
||||
> 1.9.3 is fully supported and recommended. Please note that switching to 1.9.3
|
||||
<dt>Ruby 1.9.3</dt>
|
||||
<dd>
|
||||
1.9.3 is fully supported and recommended. Please note that switching to 1.9.3
|
||||
from an earlier version will invalidate all sessions.
|
||||
</dd>
|
||||
|
||||
**Rubinius**
|
||||
> Rubinius is officially supported (Rubinius >= 1.2.4), everything works, including
|
||||
<dt>Rubinius</dt>
|
||||
<dd>
|
||||
Rubinius is officially supported (Rubinius >= 1.2.4), everything works, including
|
||||
all template languages. The upcoming 2.0 release is supported as
|
||||
well, including 1.9 mode.
|
||||
</dd>
|
||||
|
||||
**JRuby**
|
||||
> JRuby is officially supported (JRuby >= 1.6.7). No issues with third party
|
||||
<dt>JRuby</dt>
|
||||
<dd>
|
||||
JRuby is officially supported (JRuby >= 1.6.7). No issues with third party
|
||||
template libraries are known, however, if you choose to use JRuby, please
|
||||
look into JRuby rack handlers, as the Thin web server is not fully supported
|
||||
on JRuby. JRuby's support for C extensions is still experimental, which only
|
||||
affects RDiscount, Redcarpet, RedCloth and Yajl templates as well as Thin
|
||||
and Mongrel at the moment.
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
We also keep an eye on upcoming Ruby versions.
|
||||
|
||||
The following Ruby implementations are not officially supported but still are
|
||||
|
@ -2372,7 +2461,7 @@ SemVerTag.
|
|||
* [Issue tracker](http://github.com/sinatra/sinatra/issues)
|
||||
* [Twitter](http://twitter.com/sinatra)
|
||||
* [Mailing List](http://groups.google.com/group/sinatrarb/topics)
|
||||
* [IRC: #sinatra](irc://chat.freenode.net/#sinatra) on http://freenode.net
|
||||
* IRC: [#sinatra](irc://chat.freenode.net/#sinatra) on http://freenode.net
|
||||
* [Sinatra Book](http://sinatra-book.gittr.com) Cookbook Tutorial
|
||||
* [Sinatra Recipes](http://recipes.sinatrarb.com/) Community
|
||||
contributed recipes
|
||||
|
|
Loading…
Reference in New Issue