No commit activity in last 3 years
No release in over 3 years
Allows you to easily set page titles per view in your Rails 4 app, but also follows Ruby on Railsnaming conventions to set sensible default title if none is specified.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.4
~> 0.30
~> 1.3

Runtime

~> 4.0
 Project Readme

implicit_page_titles gem

Allows you to easily set page titles per view in your Rails 4 app, but also follows Ruby on Rails naming conventions to set sensible default title if none is specified.

Example

Route Page title
/ Application name
/login "Login"
/posts "Posts"
/posts/:id post.title
/author/:id author.name
/posts/:id/new "New Post"
/posts/:id/edit "Edit #{post.title}"

Usage

In your layout add the page_title helper method.

e.g. within app/views/layouts/application.html.erb

  <title><%= page_title %></title>

Explicitly setting a page title

To set a specific title for a view, call the page_title method within the view with desired title.

e.g. within app/views/welcome/index.html.erb

  <%- page_title("My page title") %>

This method will also return the set title, enabling syntax like this:

  <h1><%= page_title("My page title") %></h1>

Adding extra information to the page title

It is best to do this within the title tag:

  <title>
    <% unless current_page?(root_url) %>
      My app:
    <% end %>
    <%= page_title %>
  </title>

Compatibility

Only tested with Rails 4+ and Ruby 2+. Although untested, it would likely work with Rails 3 and Ruby 1.9.x.

License

This project rocks and uses MIT-LICENSE.