Open oliverklee opened 7 years ago
I guess this is more a case of bad documentation or confusing documentation. :default
is not an extrapolation (to use in the format string), but a option:
page_title format: ':title | :app :env', default: :'app.tagline', app: 'MyApp'
# The format string is then passed through the extrapolations and
#
# :title -> gets replaced by the title, or if there is no tagline by the option `default`
# :app -> gets replaced by the app.name or in our case by the option `app`
# :env -> if a custom registration was registered it would be replaced... like:
PageTitleHelper.interpolates :env do |env|
"[#{Rails.env}]" unless Rails.env.production?
end
does this clarify the usage of default, but reading the docs just now I had to double check it too :)
Okay, then the documentation indeed needs some improvements. :-) I've updated the ticket title accordingly.
Note to self: These are the interpolations I have been able to find so far:
:title -> namespace.controller.action.title :app -> app.name
Check out Interpolations
module here: https://github.com/lwe/page_title_helper/blob/master/lib/page_title_helper.rb#L15-L33
title
and app
are the only defined methods and thus the only known interpolations out of the box currently.
I'm using this in my HAML page layout:
If I understand the docs correctly, this should result in the translated app.tagline, a pipe, and the app.name. However, :default is output unreplaced. Am I understanding the docs incorrectly, or is this a bug?
(:app.tagline does not work either - in that case, only :app gets substituted with the translated app.name.)