Class: Rails::ComponentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Rails::ComponentsController
- Defined in:
- app/controllers/rails/components_controller.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/controllers/rails/components_controller.rb', line 17 def index @previews = ViewComponent::Preview.all @page_title = "Component Previews" # rubocop:disable GitHub/RailsControllerRenderPathsExist render "components/index" # rubocop:enable GitHub/RailsControllerRenderPathsExist end |
#previews ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/rails/components_controller.rb', line 25 def previews if params[:path] == @preview.preview_name @page_title = "Component Previews for #{@preview.preview_name}" # rubocop:disable GitHub/RailsControllerRenderPathsExist render "components/previews" # rubocop:enable GitHub/RailsControllerRenderPathsExist else @example_name = File.basename(params[:path]) @render_args = @preview.render_args(@example_name) layout = @render_args[:layout] opts = layout.nil? ? {} : { layout: layout } # rubocop:disable GitHub/RailsControllerRenderPathsExist render "components/preview", **opts # rubocop:enable GitHub/RailsControllerRenderPathsExist end end |