[ANN] a helper to DRY-up internationalized <title>'s (http://github.com/lwe/page_title_helper)

Hey there

Code and (longer) quick-start guide can also be found here:

To customize page titles there are many different methods, among the
most popular (and best looking) is certainly:
http://railscasts.com/episodes/30-pretty-page-title, even more there
are numerous plugins on github
so why was there the need to create yet another one?

Because we required a method to have internationalized titles and this
soon became very cumbersome und cludgy :slight_smile: But well, a few code
examples say more than a thousand words:

in the layout

<%= h page_title %> ...

then in the translations:

title: “All contacts”

Thats it. So if /contacts/ is called and then the view contacts/
index.html.erb is rendered, the title “All contacts” is used. To
customize the title e.g. to display the contacts name in contacts/
show.html.erb do:

in contacts/show.html.erb

<%= h page_title { @contact.name } %>

It also features some options to change the format, add custom parts
to the output etc. It can be installed as a gem, plugin or git
submodule -> http://github.com/lwe/page_title_helper If you find any
issues or problems, I’m sure there are :slight_smile: just drop me a line or
create a ticket on github.

Note: this plugin has only been tested and used on Rails 2.3.x.

Grüsse, Lukas
PS: For those interested: internally the method from railscasts is
used to set custom titles.
PPS: More examples and a description of all options can be found on
PPPS: It’s small LOC = 60, has tests (but Code to Test Ratio is only
1:1.4) and 100% code coverage.
PPPPS: Finally some bad news: it relies on some Rails internals to
e.g. obtain the first renderer etc., so if those change the plugin
might break… so if anyone knows better alternatives (check
read_first_render_path and read_page_title_content_block methods)…