1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

What's New in Sinatra 1.1?

By

What's New in Sinatra 1.1?

Sinatra 1.1 was released on Oct. 24th, 2010. What more could you possibly add to this awesome micro-framework?

Ruby 1.9.2 Compatibility

There were a few (small) bugs that prevented Sinatra 1.0 from working on Ruby 1.9.2. You can either find a workaround to these bugs, or upgrade to Sinatra 1.1 (recommended). This seems like a small thing, but it's come up a number of times.

Patterns with Before and After Filters

Before and after filters are callback methods to be run before or after certain actions. In Sinatra 1.0, you could only run before and after filters for all requests. With Sinatra 1.1, you can supply patterns just like in your actions to define which requests to wrap in these filters. In other words, where before you could only do this.


before do
 # This will run before every single request
end

You can now do this.


before('/page/*') do
 # Run this on 'page' requests
end

before('/post/:id') do|id|
 # You can even capture parameters like in actions
end

Rendering Galore

You can now render SCSS (Sass-powered CSS stylesheets) using the scss method, much like the haml and erb methods. It's never been easier to blast out stylesheets.

It's also possible to render liquid, markdown, nokogiri, textile, rdoc, radius, markaby and coffee. You'll never want for a template engine again. Before, you pretty much only had erb and Haml, now you have anything you could possibly want out of the box.

Download Resuming

Sinatra now supports the HTTP_RANGE header for static files only. What this really means is that people can resume downloads of large files through Sinatra. This makes Sinatra more suitable for serving large files, archives, videos, etc.

Much More

This is just the tip of the iceberg, there are many smaller changes you can read about in the official changelog.

  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. Sinatra
  6. What's New in Sinatra 1.1?

©2014 About.com. All rights reserved.