1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/sinatra-contrib
2011-04-26 14:27:22 +02:00
..
lib/sinatra move reloader to custom extensions 2011-04-26 14:27:22 +02:00
spec play nice if yield_content or content_for is called from outside a template 2011-04-26 11:05:14 +02:00
.gitignore some rake tasks 2011-03-29 19:40:46 +02:00
Gemfile make the reloader work on 1.8 and jRuby 2011-04-15 18:08:11 -03:00
Gemfile.lock make the reloader work on 1.8 and jRuby 2011-04-15 18:08:11 -03:00
ideas.md add template support to namespaces 2011-03-29 10:08:05 +02:00
LICENSE prepare merge 2011-03-27 17:52:30 +02:00
Rakefile dont add hidden and bundler files to gem 2011-04-22 13:48:20 +02:00
README.md move sinatra-decompile to custom extensions 2011-03-30 20:49:11 +02:00
sinatra-contrib.gemspec regenerate gemspec 2011-04-26 08:43:05 +02:00

Collection of common Sinatra extensions, semi-officially supported.

Goals

  • For every future Sinatra release, have at least one fully compatible release
  • High code quality, high test coverage
  • Include plugins people usually ask for a lot

TODO

  • Write documentation, integrate into Sinatra website
  • Finish imports and rewrites
  • Wrap up first release
  • Find contributors (both code and docs)

Included extensions

Common Extensions

These are common extension which will not add significant overhead or change any behavior of already existing APIs. They do not add any dependencies not already installed with this gem.

Currently included:

  • sinatra/config_file: Allows loading configuration from yaml files.

  • sinatra/content_for: Adds Rails-style content_for helpers to Haml, Erb, Erubis and Slim.

  • sinatra/link_header: Helpers for generating link HTML tags and corresponding Link HTTP headers. Adds link, stylesheet and prefetch helper methods.

  • sinatra/respond_with: Choose action and/or template depending automatically depending on the incoming request. Adds helpers respond_to and respond_with.

To be included soon:

  • Helpers for CSS/JS generation (currently in sinatra-support)

  • Rewrite of sinatra-reloader

Custom Extensions

These extensions may add additional dependencies and enhance the behavior of the existing APIs.

Currently included:

  • sinatra/decompile: Recreates path patterns from Sinatra's internal data structures (used by other extensions)/

To be included soon:

  • Rewrite of sinatra-compass

Other Tools

  • sinatra/extension: Mixin for writing your own Sinatra extensions.

  • sinatra/test_helpers: Helper methods to ease testing your Sinatra application. Partly extracted from Sinatra. Testing framework agnostic

Usage

Classic Style

A single extension (example: sinatra-content-for):

require 'sinatra'
require 'sinatra/content_for'

Common extensions:

require 'sinatra'
require 'sinatra/contrib'

All extensions:

require 'sinatra'
require 'sinatra/contrib/all'

Modular Style

A single extension (example: sinatra-content-for):

require 'sinatra/base'
require 'sinatra/content_for'

class MyApp < Sinatra::Base
  register Sinatra::ContentFor
end

Common extensions:

require 'sinatra/base'
require 'sinatra/contrib'

class MyApp < Sinatra::Base
  register Sinatra::Contrib
end

All extensions:

require 'sinatra/base'
require 'sinatra/contrib'

class MyApp < Sinatra::Base
  register Sinatra::Contrib
end