bullet-train-co / nice_partials

A little bit of magic to make partials perfect for components.
MIT License
289 stars 16 forks source link

`partial.helpers` are shared across all partials #102

Open grncdr opened 2 months ago

grncdr commented 2 months ago

I'm not sure if this is an issue or if I'm misreading the README, but from "well isolated helper methods" I expected that helpers defined with partial.helpers would only be available to the partial that defines them. Instead, it appears that helpers defined in this way are available to all partials.

To reproduce:

  1. Clone https://github.com/grncdr/nice_partials_issue
  2. Checkout the issue-102 branch
  3. bundle && rails server
  4. Open localhost:3000
  5. Observe the empty red box
  6. Uncomment this line: https://github.com/grncdr/nice_partials_issue/blob/issue-101/app/views/pages/index.html.erb#L2
  7. Refresh*
  8. Observe that the helper defined in test_partial is available on other_partial.

* - you may need to restart the server to observe the changes, see #101

kaspth commented 2 months ago

Yeah, we're aware of this, but I haven't found a reliable way to fix it yet.

"isolated" there refers to having the helpers scoped just to partials, versus also having helper SomethingHelper expose them elsewhere.