Project

body_id

0.0
No commit activity in last 3 years
No release in over 3 years
Insert body_id within your application layout's <body> tag. Pages#Index becomes "#page-index" You can overwrite the generated ID with a custom ID from within your controller's action by set @body_id to your desired ID
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.5
>= 0
 Project Readme

body_id

body_id logo

Create a custom body_id from your controller and action names.

Pages#index #=> #page-index
Cars#new #=> #car-new

Installation

Add this line to your application's Gemfile:

gem 'body_id'

And then execute:

$ bundle

Or install it yourself as:

$ gem install body_id

Usage

In your application.html.erb, or other layout files, set body_id as the body tag's ID ###ERB

...
</head>
    <body id= <%= body_id %>>
        <%= yield %>
    </body>
</html>

###HAML

...
%body{ id: "#{ body_id }" }
...

Custom body_id

In case you want a custom ID for your body tag, simply create an instance variable with what you want the view's body_id to be.

class PagesContrller < ApplicationController
  def index
    @body_id = 'home'
  end

  def new
    @body_id = 'awesome-custom-id'
  end
end

Contributing

  1. Fork it ( http://github.com/the4dpatrick/body-id-gem )
  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