GithubHelp home page GithubHelp logo

vipulnsward / sinatra-contrib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sinatra/sinatra-contrib

0.0 1.0 0.0 309 KB

Collection of common Sinatra extensions

Home Page: http://www.sinatrarb.com/contrib/

License: MIT License

Ruby 98.91% CSS 0.01% HTML 1.08%

sinatra-contrib's Introduction

Build Status

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

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/capture: Let's you capture the content of blocks in templates.

  • 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/cookies: A cookies helper for reading and writing cookies.

  • sinatra/engine_tracking: Adds methods like haml? that allow helper methods to check whether they are called from within a template.

  • sinatra/json: Adds a #json helper method to return JSON documents.

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

  • sinatra/multi_route: Adds ability to define one route block for multiple routes and multiple or custom HTTP verbs.

  • sinatra/namespace: Adds namespace support to Sinatra.

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

  • sinatra/custom_logger: This extension allows you to define your own logger instance using +logger+ setting. That logger then will be available as #logger helper method in your routes and views.

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).

  • sinatra/reloader: Automatically reloads Ruby files on code changes.

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

Installation

Add gem 'sinatra-contrib' to Gemfile, then execute bundle install.

If you don't use Bundler, install the gem manually by executing gem install sinatra-contrib in your command line.

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'
require 'sinatra/namespace'

class MyApp < Sinatra::Base
  # Note: Some modules are extensions, some helpers, see the specific
  # documentation or the source
  helpers Sinatra::ContentFor
  register Sinatra::Namespace
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/all'

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

Documentation

For more info check the official docs and api docs.

sinatra-contrib's People

Contributors

rkh avatar gnandretta avatar trevorbramble avatar kytrinyx avatar foca avatar shime avatar rafmagana avatar kamui avatar license2e avatar kgrz avatar ortuna avatar vipulnsward avatar lest avatar bjeanes avatar vidbina avatar slowernet avatar xentek avatar jamiehodge avatar kylewlacy avatar frost avatar allaire avatar yesmeck avatar patriciomacadden avatar dinduks avatar thibautsacreste avatar udzura avatar willbailey avatar undr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.