README.md in actionview-component-1.15.0 vs README.md in actionview-component-1.16.0
- old
+ new
@@ -195,10 +195,28 @@
<div class="header">Hello Jane</div>
<div class="body"><p>Have a great day.</p></div>
</div>
```
+### Inline Component
+
+A component can be rendered without any template file as well.
+
+`app/components/inline_component.rb`:
+
+```ruby
+class InlineComponent < ViewComponent::Base
+ def call
+ if active?
+ link_to "Cancel integration", integration_path, method: :delete
+ else
+ link_to "Integrate now!", integration_path
+ end
+ end
+end
+```
+
### Conditional Rendering
Components can implement a `#render?` method to determine if they should be rendered.
For example, given a component that displays a banner to users who haven't confirmed their email address, the logic for whether to render the banner would need to go in either the component template:
@@ -245,9 +263,11 @@
`app/views/_banners.html.erb`
```erb
<%= render(ConfirmEmailComponent.new(user: current_user)) %>
```
+
+To assert that a component has not been rendered, use `refute_component_rendered` from `ViewComponent::TestHelpers`.
### Testing
Unit test components directly, using the `render_inline` test helper and Capybara matchers: