From 382126750f473bb764e20e11e52bd0b14c795ea5 Mon Sep 17 00:00:00 2001 From: Joel Hawksley Date: Tue, 5 Jul 2022 13:53:02 +0100 Subject: [PATCH] update docs around rendering in controllers (#1404) * update docs around rendering in controllers see https://github.com/github/view_component/issues/1322 * vale * grammar * Update docs/guide/getting-started.md Co-authored-by: Simon Fish Co-authored-by: Simon Fish --- docs/CHANGELOG.md | 7 +++++++ docs/guide/getting-started.md | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a92c45826..4982193b8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,10 @@ title: Changelog ## main +* Update docs to reflect lack of block content support in controllers. + + *Joel Hawksley* + * Prevent adding duplicates to `autoload_paths`. *Thomas Hutterer* @@ -18,6 +22,9 @@ title: Changelog *Simon Fish* * Include polymorphic slots in `ViewComponent::Base` by default. + + *Cameron Dutro* + * Add per-component config option for stripping newlines from templates before compilation. *Cameron Dutro* diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 6db6bf887..262d8a42d 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -90,11 +90,11 @@ It's also possible to render ViewComponents in controllers: ```ruby # app/controllers/home_controller.rb def show - render(ExampleComponent.new(title: "My Title")) { "Hello, World!" } + render(ExampleComponent.new(title: "My Title")) end ``` -_In versions of Rails < 6.1, rendering a ViewComponent from a controller doesn't include the layout._ +_Note: Content can't be passed to a component via a block in controllers. Instead, use `with_content`. In versions of Rails < 6.1, rendering a ViewComponent from a controller doesn't include the layout._ ### Rendering ViewComponents to strings inside controller actions