Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhawksley committed Jul 2, 2020
1 parent a7e57c7 commit 12e8666
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -713,17 +713,16 @@ config.view_component.preview_path = "#{Rails.root}/spec/components/previews"

### Disabling the render monkey patch (Rails < 6.1)

In order to [resolve conflicts](https://github.com/github/view_component/issues/288) on `Rails < 6.1` between ViewComponent other gems also monkey patching the `render` method, it is possible to configure ViewComponent to not include the render monkey patch:
In order to [avoid conflicts](https://github.com/github/view_component/issues/288) between ViewComponent and other gems that also monkey patch the `render` method, it is possible to configure ViewComponent to not include the render monkey patch:

`config.view_component.render_monkey_patch_enabled = false # defaults to true`

If the option is set to `false` ViewComponent will *NOT* monkey patch the render method and it is not possible to render view components using `render`. Use `render_component` (or `render_component_to_string`) instead:
With the monkey patch disabled, use `render_component` (or `render_component_to_string`) instead:

```
<%= render_component Component.new(message: "bar") %>
```


### Sidecar assets (experimental)

It’s possible to include Javascript and CSS alongside components, sometimes called "sidecar" assets or files.
Expand Down
5 changes: 1 addition & 4 deletions lib/view_component/base.rb
Expand Up @@ -162,10 +162,7 @@ def request
mattr_accessor :test_controller
@@test_controller = "ApplicationController"

# Option to configure if render monkey patches should be inluded or not.
# If set to true and rails version < 6.1 render monkey patches will be included.
# If set to false and rails version < 6.1 render moneky patches will not be included.
# In this case the method render_component can be used for rendering components.
# Configure if render monkey patches should be included or not in Rails <6.1.
mattr_accessor :render_monkey_patch_enabled, instance_writer: false, default: true

class << self
Expand Down

0 comments on commit 12e8666

Please sign in to comment.