komposable / komponent

An opinionated way of organizing front-end code in Ruby on Rails, based on components
http://komponent.io
MIT License
427 stars 31 forks source link

Fix translation lookup in partials #116

Closed stevschmid closed 6 years ago

stevschmid commented 6 years ago

We noticed that the translation lookup in partials was broken. Using the helper t('.key') in partial bar within a component foo would lookup the key in the scope of bar_component instead of foo_component.

This PR addresses this issue. In the example above, the resulting key from the helper would be foo_component.bar.key

This PR is not compatible with the way komponent handles namespacing at the moment, please do not merge! Refer to #117

coveralls commented 6 years ago

Pull Request Test Coverage Report for Build 548


Files with Coverage Reduction New Missed Lines %
lib/komponent/komponent_helper.rb 1 83.33%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 537: 0.04%
Covered Lines: 129
Relevant Lines: 130

💛 - Coveralls
stevschmid commented 6 years ago

I just added compatibility in 6b72af9 for the current namespacing layout (see #117). It seems code climate does not like my code → "Cognitive Complexity of 6". Alas, I don't have the mental strength right now to address this too.

Spone commented 6 years ago

Thanks! I'll take care of refactoring to make Code Climate happy.

Spone commented 6 years ago

Done. Would you mind adding an item in the Changelog, and maybe describe this behavior in the Readme?

stevschmid commented 6 years ago

Sure thing! I just added a line to the changelog. Do you think it's necessary to explain the behavior in the README? I personally think it's quite intuitive and consistent with the "Rails way".

Spone commented 6 years ago

You're right, let's merge :)