actionview-component 1.7.0 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE +5 -8
- data/.github/PULL_REQUEST_TEMPLATE +2 -4
- data/.github/workflows/ruby_on_rails.yml +6 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +150 -0
- data/CONTRIBUTING.md +10 -19
- data/Gemfile.lock +20 -5
- data/README.md +204 -248
- data/actionview-component.gemspec +10 -8
- data/{lib/railties/lib → app/controllers}/rails/components_controller.rb +18 -8
- data/docs/case-studies/jellyswitch.md +76 -0
- data/lib/action_view/component.rb +1 -20
- data/lib/action_view/component/base.rb +2 -246
- data/lib/action_view/component/preview.rb +1 -80
- data/lib/action_view/component/railtie.rb +1 -64
- data/lib/action_view/component/test_case.rb +1 -3
- data/lib/action_view/component/test_helpers.rb +1 -19
- data/lib/rails/generators/component/component_generator.rb +6 -12
- data/lib/rails/generators/component/templates/component.rb.tt +0 -4
- data/lib/rails/generators/erb/component_generator.rb +21 -0
- data/lib/rails/generators/erb/templates/component.html.erb.tt +1 -0
- data/lib/rails/generators/haml/component_generator.rb +21 -0
- data/lib/rails/generators/haml/templates/component.html.haml.tt +1 -0
- data/lib/rails/generators/rspec/component_generator.rb +1 -1
- data/lib/rails/generators/rspec/templates/component_spec.rb.tt +1 -1
- data/lib/rails/generators/slim/component_generator.rb +21 -0
- data/lib/rails/generators/slim/templates/component.html.slim.tt +1 -0
- data/lib/rails/generators/test_unit/component_generator.rb +1 -1
- data/lib/rails/generators/test_unit/templates/component_test.rb.tt +3 -3
- data/lib/railties/lib/rails.rb +0 -1
- data/lib/railties/lib/rails/templates/rails/components/preview.html.erb +1 -1
- data/lib/view_component.rb +30 -0
- data/lib/view_component/base.rb +279 -0
- data/lib/view_component/conversion.rb +9 -0
- data/lib/view_component/engine.rb +65 -0
- data/lib/view_component/preview.rb +78 -0
- data/lib/view_component/previewable.rb +25 -0
- data/lib/view_component/render_monkey_patch.rb +31 -0
- data/lib/view_component/rendering_monkey_patch.rb +13 -0
- data/lib/view_component/template_error.rb +9 -0
- data/lib/view_component/test_case.rb +9 -0
- data/lib/view_component/test_helpers.rb +39 -0
- data/lib/view_component/version.rb +11 -0
- data/script/console +1 -1
- metadata +48 -21
- data/lib/action_view/component/conversion.rb +0 -11
- data/lib/action_view/component/previewable.rb +0 -27
- data/lib/action_view/component/render_monkey_patch.rb +0 -29
- data/lib/action_view/component/template_error.rb +0 -11
- data/lib/action_view/component/version.rb +0 -13
- data/lib/rails/generators/component/templates/component.html.erb.tt +0 -5
- data/lib/railties/lib/rails/component_examples_controller.rb +0 -9
- data/lib/railties/lib/rails/templates/rails/examples/show.html.erb +0 -1
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "active_support/concern"
|
4
|
-
|
5
|
-
module ActionView
|
6
|
-
module Component # :nodoc:
|
7
|
-
module Previewable
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
included do
|
11
|
-
# Set the location of component previews through app configuration:
|
12
|
-
#
|
13
|
-
# config.action_view_component.preview_path = "#{Rails.root}/lib/component_previews"
|
14
|
-
#
|
15
|
-
mattr_accessor :preview_path, instance_writer: false
|
16
|
-
|
17
|
-
# Enable or disable component previews through app configuration:
|
18
|
-
#
|
19
|
-
# config.action_view_component.show_previews = true
|
20
|
-
#
|
21
|
-
# Defaults to +true+ for development environment
|
22
|
-
#
|
23
|
-
mattr_accessor :show_previews, instance_writer: false
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Monkey patch ActionView::Base#render to support ActionView::Component
|
4
|
-
#
|
5
|
-
# A version of this monkey patch was upstreamed in https://github.com/rails/rails/pull/36388
|
6
|
-
# We'll need to upstream an updated version of this eventually.
|
7
|
-
module ActionView
|
8
|
-
module Component
|
9
|
-
module RenderMonkeyPatch # :nodoc:
|
10
|
-
def render(options = {}, args = {}, &block)
|
11
|
-
if options.respond_to?(:render_in)
|
12
|
-
ActiveSupport::Deprecation.warn(
|
13
|
-
"passing component instances (`render MyComponent.new(foo: :bar)`) has been deprecated and will be removed in v2.0.0. Use `render MyComponent, foo: :bar` instead."
|
14
|
-
)
|
15
|
-
|
16
|
-
options.render_in(self, &block)
|
17
|
-
elsif options.is_a?(Class) && options < ActionView::Component::Base
|
18
|
-
options.new(args).render_in(self, &block)
|
19
|
-
elsif options.is_a?(Hash) && options.has_key?(:component)
|
20
|
-
options[:component].new(options[:locals]).render_in(self, &block)
|
21
|
-
elsif options.respond_to?(:to_component_class) && !options.to_component_class.nil?
|
22
|
-
options.to_component_class.new(options).render_in(self, &block)
|
23
|
-
else
|
24
|
-
super
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/application_controller"
|
4
|
-
load "config/application.rb" unless Rails.root
|
5
|
-
|
6
|
-
class Rails::ComponentExamplesController < ActionController::Base # :nodoc:
|
7
|
-
prepend_view_path File.expand_path("templates/rails", __dir__)
|
8
|
-
append_view_path Rails.root.join("app/views")
|
9
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= raw @example %>
|