bridgetownrb / bridgetown-view-component

Add support for GitHub's ViewComponent library to your Bridgetown sites.
MIT License
10 stars 1 forks source link

Document how the ActionView helpers allowlist works #1

Closed jaredcwhite closed 3 years ago

jaredcwhite commented 3 years ago

Most ActionView helpers are blocked from use within Bridgetown (because some don't work well or have conflicts), but this is configurable and should be documented so folks can tweak accordingly.

andrewmcodes commented 3 years ago

@jaredcwhite I was just about to open a PR to change this bc I didn’t know this was an option. How would one go about it? I can open a doc PR if it works!

jaredcwhite commented 3 years ago

@andrewmcodes So when you include Bridgetown::ViewComponentHelpers in your VCs, that runs through a list of ActionView helpers and actually removes them from the instance methods available. To skip removing certain helpers you want to use, you'd add a call within your VC class (or in a base class should do the trick):

allow_rails_helpers :helper_one, :helper_two

You'll find that all in the ViewComponentHelpers class definition.

jaredcwhite commented 3 years ago

This is all because a bunch of stuff in ActionView assumes Rails is around and breaks, or conversely it interferes with Bridgetown helpers. Perhaps over time we can expand the default allow list as we test various scenarios.

andrewmcodes commented 3 years ago

Ahhhh I see

You'll find that all in the ViewComponentHelpers class definition.

Makes sense! I had the code up on a private branch and everything so glad I saw this.

I'll give it a try and open a PR.