Closed sandstrom closed 1 year ago
@sandstrom Yeah, seems like a mistake. We could just switch from model.locales
to model.attributes[:locales]
which wouldn't trigger a warning. The warning is for the benefit of users, not for our internal purposes.
@jaredcwhite Thanks!
I've opened a PR, I hope it does the job: https://github.com/bridgetownrb/bridgetown/pull/748
I noticed this issue: https://github.com/bridgetownrb/bridgetown/issues/681
Basically, it's about output that looks like this if you have a lot of
.multi
pages and nolocale
property set in the frontmatter.This is the line that triggers the warning: https://github.com/bridgetownrb/bridgetown/blob/main/bridgetown-core/lib/bridgetown-core/collection.rb#L285
And this is the actual warning being printed out: https://github.com/bridgetownrb/bridgetown/blob/main/bridgetown-core/lib/bridgetown-core/model/base.rb#L154
PR questions
Are you open to changing this?
The two options I think is best:
model.my_key
tomodel.front_matter.retrieve('my_key')
ormodel.retrieve_front_matter('my_key')
and then let the retrieve method make warnings configurable, i.e.retrieve(key, unknown_warning: true)
, and then invoke it with no warning fromcollection.rb
.(I cannot judge the work for (2) though, but overall I think method_missing is often a source of confusion, and ideally accessing things explicitly is better, but I don't know enough about internals to judge if this is a good idea here)