This project is archived and is in readonly mode.
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
-
David Knorr May 16th, 2009 @ 05:17 PM
- no changes were found...
-
Pratik May 17th, 2009 @ 01:34 PM
- Title changed from [Patch] Helper for generating the <title> tag to Helper for generating the <title> tag
-
Pratik May 17th, 2009 @ 01:39 PM
- State changed from new to wontfix
Not sure if I'd use this helper for setting title. People typically use http://railscasts.com/episodes/30-pretty-page-title for setting title. Probably you should ask in the core mailing list and see if more people find this useful. In which case, we can reevaluate the patch.
Thanks.
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>