Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the documentation of the format and of interpolations #56

Open
oliverklee opened this issue Jan 20, 2017 · 4 comments
Open

Improve the documentation of the format and of interpolations #56

oliverklee opened this issue Jan 20, 2017 · 4 comments

Comments

@oliverklee
Copy link
Collaborator

I'm using this in my HAML page layout:

%title= page_title format: ':default | :app'

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.)

@lwe
Copy link
Owner

lwe commented Jan 24, 2017

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 :)

@oliverklee oliverklee changed the title Fix app.tagline (or explain it better) Improve the documentation of the format and of interpolations Jan 24, 2017
@oliverklee
Copy link
Collaborator Author

Okay, then the documentation indeed needs some improvements. :-) I've updated the ticket title accordingly.

@oliverklee
Copy link
Collaborator Author

Note to self: These are the interpolations I have been able to find so far:

:title -> namespace.controller.action.title
:app -> app.name

@lwe
Copy link
Owner

lwe commented Jan 26, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants