Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Some extensions to the sinatra default behavior (usefull for other Sintatra extensions, extracted from BigBand).

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib do not change sinatra behavior May 02, 2011
Octocat-spinner-32 spec do not change sinatra behavior May 02, 2011
Octocat-spinner-32 LICENSE added license May 02, 2010
Octocat-spinner-32 sinatra 0.9 is no longer supported May 02, 2010
Octocat-spinner-32 sinatra-sugar.gemspec


Basic Sinatra extension (mainly extending Sinatra's standard methods, like set or register). Also it features a more advanced path guessing than Sinatra::Base.

Normally you do not have to register this module manually, as the other extensions will do so if necessary.


Sinatra::Sugar is part of the BigBand stack. Check it out if you are looking for other fancy Sinatra extensions.


gem install sinatra-sugar

More advanced set

  • Adds set_#{key} and set_value hooks to set.
  • Merges the old value with the new one, if both are hashes:

    set :haml, :format => :html5, :escape_html => true
    set :haml, :excape_html => false
    haml # => { :format => :html5, :escape_html => false }

More advanced register

If an extension is registered twice, the registered hook will only be called once.

Ability to extend command line options


require "sinatra/base"
require "sinatra/sugar"

class App < Sinatra::Base
  register Sinatra::Sugar
  run_option_parser.on("-i") { puts "yes, -i is a nice option" }
  run! if $0 == __FILE__

Exposes caller usage of Sinatra

This is for extension developers only. If you modify some core methods, you don't want your ruby file to be mistaken for the app_file. You can fix it this way:

require "sinatra/base"
require "sinatra/sugar"
module Sinatra
  module HardcoreExtension
    # ...
  register HardcoreExtension
Something went wrong with that request. Please try again.