No commit activity in last 3 years
No release in over 3 years
Decorate your <body> with CSS Classes indicating platform, browser, browser version, and more.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Rack::BodyClasses

Decorate your <body> with CSS Classes indicating platform, browser, browser version, and more.

Project Status

  • Build: Build Status
  • Dependencies: Dependency Status
  • Code Quality: Code Climate

Installation

Add this line to your application's Gemfile:

gem 'rack-body_classes'

And then execute:

$ bundle

Usage

First, add the middlware to your application...

Rack/Sinatra

use Rack::BodyClasses

Rails

config.middleware.use Rack::BodyClasses

Then, in your layout, output env['rack.body_classes'] in your <body> tag's class attribute.

Here's a trivial layout file, formatted with the slim templating engine, to give you an example:

html
  head
  body class="#{env['rack.body_classes']}"
    == yield

When rendered, the body tag will look something like this:

<body class="desktop chrome modern mac webkit">

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Shout Outs

This middleware is made possible by Browser gem and MobileESP (converted) gem and borrows a bit of code from Mobvious gem. Mad props and many thank yous to these gem authors.