This project is archived and is in readonly mode.

#2657 ✓wontfix
David Knorr

Helper for generating the <title> tag

Reported by David Knorr | May 16th, 2009 @ 04:32 PM | in 2.x

I don't know about you, but I'm pretty tired of always having to add a helper for generating the "title" tag to my Rails applications. Of course, this could easily be turned into a plugin, but such a small piece of functionality that is so common and essential should really be in the core.

Therefore, I put together a patch that adds a TitleHelper module to ActionView::Helpers containing just a single method called "title". Here is an example:

# Setting the title. For use in <h1> tags, e.g.
title('Welcome')
# => Welcome

title(:site => 'Site')
# => <title>Site - Welcome</title>

Two other options are available:

  • separator for defining the separator between site name and title. Default is " - ".
  • reverse for reversing the order of site name and title. Default is false, site name first.

Alternatively, the helper could be merged into one of the existing helper modules, e.g. the TagHelper module. Test coverage and documentation should be fine.

Ideas are always welcome. :)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages