Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Headliner

Headliner

========= Headliner DRYs up your page titles.

Background

Normally, if your Rails application has lots of actions and a shared layout, you might find yourself setting custom page title names in your controllers.

Here’s an example:

class PagesController < ApplicationController def about @title = “About us” end end

Then, in your main layout, you might have something like this:

<head> <title>My website<% if @title >: <= @title >< end %></title> </head><head> <%= title :site => “My website” %> </head>

Then, to set the page title, add this to each of your views:

<%= title “My page title” %>

When views are rendered, the page title will be included in the right spots:

<head> <title>My website | My page title</title> </head> <body> My page title </body>

Options

Use these options to customize the title format:

:prefix (text between site name and separator) :separator (text used to separate website name from page title) :suffix (text between separator and page title) :lowercase (when true, the page name will be lowercase) :reverse (when true, the page and site names will be reversed)

And here are a few examples to give you ideas.

<%= title :separator => ”—README and so the formatting may need updating to make browser friendly