GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sinefunc/sinatra-support: Bare metal helpers for your sinatra app

BranchesTags
Open more actions menu

Latest commit

 

History

91 Commits
91 Commits

Folders and files

NameName
Last commit message
Last commit date
lib/sinatra
lib/sinatra
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.yardopts
.yardopts
 
 
Gemfile
Gemfile
 
 
HISTORY.md
HISTORY.md
 
 
LICENSE
LICENSE
 
 
README.rdoc
README.rdoc
 
 
Rakefile
Rakefile
 
 
sinatra-support.gemspec
sinatra-support.gemspec
 
 

Repository files navigation

Sinatra Support

A collection of useful utilities.

Sinatra Support’s mission is to implement the things web apps will need 90% of the time. Think of it as Rails’s conveniences done the Sinatra way.

  • Documentation: sinefunc.com/sinatra-support

  • Source: github.com/sinefunc/sinatra-support

Plugins

{Sinatra::CssSupport}

Provides CSS/Sass/Less support.

{Sinatra::JsSupport}

Provides JavaScript/CoffeeScript support.

{Sinatra::Numeric}

Helpers for showing percentages and currencies.

{Sinatra::DateForms}

Provides dropdowns for year/month/date.

{Sinatra::I18nSupport}

Provides I18n support.

{Sinatra::MultiRender}

Allow rendering from multiple view paths and auto-guessing template engines.

{Sinatra::CompassSupport}

Adds support for the Compass CSS framework.

{Sinatra::CompressedJS}

JavaScript compression.

{Sinatra::AppModule}

Write parts of your application as a module.

Helpers

{Sinatra::CountryHelpers}

Country dropdowns and stuff.

{Sinatra::HtmlHelpers}

Provides many common HTML helpers.

{Sinatra::IfHelpers}

Common HAML condition helpers.

{Sinatra::UserAgentHelpers}

Browser detection.

{Sinatra::OhmErrorHelpers}

Allows you to present errors nicely in HAML templates.

How to use

Require the Sinatra support gem. For those using Bundler, that is:

# Gemfile
gem "sinatra-support", require: "sinatra/support"

Or otherwise:

# gem install sinatra-support
require 'sinatra/support'

In your Sinatra application, use register or helpers to add in plugins as you need them.

class Main < Sinatra::Base
  register Sinatra::DateForms
  helpers  Sinatra::HtmlHelpers
  helpers  Sinatra::CountryHelpers
end

Common examples

Provided by {Sinatra::UserAgentHelpers}:

Detect browser versions easily.

helpers Sinatra::UserAgentHelpers

if browser.ios? && !browser.ipad?
  redirect '/touch'
end

Provided by {Sinatra::CssSupport}:

Serve up dynamic stylesheets (Sass/Less) with ease. Dynamic JavaScript files (CoffeeScript) are also available via {Sinatra::JsSupport}.

register Sinatra::CssSupport
serve_css '/css', from: './app/css'

# curl "http://localhost:4567/css/print.css"   # reads app/css/print.sass 
                                               # (or .less, .scss, .css)

Provided by {Sinatra::IfHelpers}:

Conditional helpers for HAML (checked_if, hide_if, etc):

%input{checked_if(page.available?), type: 'checkbox'}
%div#comments{hide_if(post.comments.empty?)}

Provided by {Sinatra::CountryHelpers}:

<select name="country"><%= select_options country_choices %></select>

Provided by {Sinatra::DateForms}:

<select name="birthday[month]"><%= month_choices %></select>
<select name="birthday[day]"><%= day_choices %></select>
<select name="birthday[year]"><%= year_choices %></select>

Provided by {Sinatra::Numeric}:

<%= currency(100) %><!-- $100 -->
<%= percentage(100) %><!-- 100.00% -->

Provided by {Sinatra::HtmlHelpers}:

<%= h "<Bar>" %>

<select name="categories">
  <%= select_options [['First', 1], ['Second', 2]] %>
</select>

Starting a new project?

Also consider Rico Sta. Cruz’s sinatra-template which already preloads some of Sinatra Support’s conveniences and more. github.com/rstacruz/sinatra-template

Copyright

Copyright © 2009-2011 Cyril David, Rico Sta. Cruz and Sinefunc, Inc. See LICENSE for details.

About

Bare metal helpers for your sinatra app

sinefunc.com/sinatra-support

Resources

Readme
MIT license
Activity

Stars

38 stars

Watchers

3 watching

Forks

6 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.