Using Extensions
Extensions provide helper or class methods for Sinatra
applications.
These methods are customarily listed and described on extensions home
pages, many of which are listed below.
Using an extension is usually as simple as installing a gem or library and requiring a file. Consult these steps if you run into problems:
Install the gem or vendor the library with your project:
gem install sinatra-prawn
Require the extension in your application:
require 'sinatra/prawn'
If your application is "classic" (i.e., you
require 'sinatra'
and define the application in the main/top-level context), you're done. The extension methods should be available to your application.If your application subclasses
::Sinatra::Base
, you have to register the extension in your subclass:register Sinatra::Prawn
Helper Extensions
These extensions add helper methods to the request context:
- sinatra-prawn adds support for PDF rendering with Prawn templates.
- sinatra-markaby enables rendering of HTML files using markaby templates.
- sinatra-maruku provides Maruku templates for a Sinatra application.
- sinatra-rdiscount provides RDiscount templates for a Sinatra application.
- sinatra-effigy provides Effigy templates and views for a Sinatra application.
- sinatra-content-for
provides
content_for
helper similar to Rails one. - sinatra-url-for construct absolute paths and full URLs to actions in a Sinatra application
- sinatra-static-assets
implements
image_tag
,stylesheet_link_tag
,javascript_script_tag
andlink_tag
helpers. These helpers construct correct absolute paths for applications dispatched to sub URI. - sinatra-mapping
implements
map
in the DSL syntax commands which creates dynamicallymapname_path
method. - sinatra_more Library with agnostic generators, form builders, named route mappings, easy mailer support among other functionality.
- sinatra-authorization HTTP auth helpers
- sinatra-simple-navigation enables creating navigations using the simple-navigation gem.
DSL Extensions
These extensions add methods to Sinatra's application DSL:
- snap provides support for named routes and helper methods for building URLs for use in links and redirects.
Extensions which handle setup and configuration
- sinatra-mongoid sets up a MongoDB connection, provides Mongoid to your app, and provides options for configuration.
Add more! See Writing Extensions for more information about creating your own.