README.rdoc in lwe-page_title_helper-0.4.0 vs README.rdoc in lwe-page_title_helper-0.5.0
- old
+ new
@@ -59,12 +59,12 @@
page_title :format => ':title / :app' # => "Contacts / My cool app"
Adding custom interpolations is as easy as defining a block, for example to access the current
controller:
- PageTitleHelper.interpolates :controller do |title,options|
- controller.class.humanize
+ PageTitleHelper.interpolates :controller do |env|
+ env.controller.controller_name.humanize
end
page_title :format => ':title / :controller / :app' # => "Welcome back / Dashboard / My cool app"
To access just the title, without any magic app stuff interpolated or appended, use:
@@ -75,18 +75,33 @@
== All options - explained
* <tt>page_title { ... }</tt> - not per se an option, but if a block is given the methods sets a
custom title and overwrites any DRY-I18n title.
* <tt>:app</tt> - specifiy the applications name, however it's recommended to define the
- translation key <tt>:'app.name'</tt>. If set to <tt>true</tt>, just returns the app name,
- as defined in the translations or based on the +RAILS_ROOT+ humanized basename.
+ translation key <tt>:'app.name'</tt> or use the the fallback behaviour for the humanzied
+ basename of +RAILS_ROOT+.
* <tt>:default</tt> - string which is displayed when no translation exists and no custom title
has been specified. Can also be set to a symbol or array to take advantage of
<tt>I18n.translate</tt>s <tt>:default</tt> option. (Default is <tt>:'app.tagline'</tt>)
* <tt>:format</tt> - defines the output format, accepts a string containing multiple interpolations,
see <i>More fun with <tt>:format</tt></i>. If set to +false+, just the current title is returned.
+ If <tt>:format => :app</tt> then just the application name is returned.
(Default is <tt>":app - :title"</tt>)
* <tt>:suffix</tt> - not happy with the fact that the translations must be named like
<tt>en -> contacts -> index -> title</tt>, but prefer e.g. them to be suffixed with
<tt>page_title</tt>? Then just set <tt>:suffix => :page_title</tt>. (Default <tt>:title</tt>)
+If an option should be set globally it's possible to change the default options hash as follows:
+
+ PageTitleHelper.options[:format] = ':title / :app'
+
+Note, currently it only makes sense to set <tt>:format</tt> and/or <tt>:default</tt> globally.
+
+== Some (maybe useful) interpolations
+
+ # internationalized controller names, with fallback
+ PageTitleHelper.interpolates :controller do |env|
+ I18n.t env.controller.controller_path.tr('/','.') + '.controller', :default => env.controller.controller_name.humanize
+ end
+
+== Licence and copyright
Copyright (c) 2009 Lukas Westermann (Zurich, Switzerland), released under the MIT license