view_component 2.50.0 → 2.69.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/app/assets/vendor/prism.css +3 -195
- data/app/assets/vendor/prism.min.js +11 -11
- data/app/controllers/concerns/view_component/preview_actions.rb +97 -0
- data/app/controllers/view_components_controller.rb +1 -87
- data/app/helpers/preview_helper.rb +5 -5
- data/app/views/view_components/preview.html.erb +2 -2
- data/docs/CHANGELOG.md +427 -1
- data/lib/rails/generators/abstract_generator.rb +7 -9
- data/lib/rails/generators/component/component_generator.rb +5 -4
- data/lib/rails/generators/locale/component_generator.rb +1 -1
- data/lib/rails/generators/preview/component_generator.rb +1 -1
- data/lib/view_component/base.rb +152 -51
- data/lib/view_component/collection.rb +9 -2
- data/lib/view_component/compiler.rb +39 -18
- data/lib/view_component/config.rb +159 -0
- data/lib/view_component/content_areas.rb +1 -1
- data/lib/view_component/docs_builder_component.rb +1 -1
- data/lib/view_component/engine.rb +16 -30
- data/lib/view_component/polymorphic_slots.rb +28 -1
- data/lib/view_component/preview.rb +12 -9
- data/lib/view_component/render_component_helper.rb +1 -0
- data/lib/view_component/render_component_to_string_helper.rb +1 -1
- data/lib/view_component/render_to_string_monkey_patch.rb +1 -1
- data/lib/view_component/rendering_component_helper.rb +1 -1
- data/lib/view_component/rendering_monkey_patch.rb +1 -1
- data/lib/view_component/slot_v2.rb +4 -10
- data/lib/view_component/slotable.rb +5 -6
- data/lib/view_component/slotable_v2.rb +69 -21
- data/lib/view_component/test_helpers.rb +80 -8
- data/lib/view_component/translatable.rb +13 -14
- data/lib/view_component/version.rb +1 -1
- data/lib/view_component.rb +1 -0
- metadata +47 -18
- data/lib/view_component/previewable.rb +0 -62
@@ -9,7 +9,7 @@ module ViewComponent
|
|
9
9
|
|
10
10
|
RESERVED_NAMES = {
|
11
11
|
singular: %i[content render].freeze,
|
12
|
-
plural: %i[contents renders].freeze
|
12
|
+
plural: %i[contents renders].freeze
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
# Setup component slot state
|
@@ -17,9 +17,19 @@ module ViewComponent
|
|
17
17
|
# Hash of registered Slots
|
18
18
|
class_attribute :registered_slots
|
19
19
|
self.registered_slots = {}
|
20
|
+
|
21
|
+
class_attribute :_warn_on_deprecated_slot_setter
|
22
|
+
self._warn_on_deprecated_slot_setter = false
|
20
23
|
end
|
21
24
|
|
22
25
|
class_methods do
|
26
|
+
##
|
27
|
+
# Enables deprecations coming to the Slots API in ViewComponent v3
|
28
|
+
#
|
29
|
+
def warn_on_deprecated_slot_setter
|
30
|
+
self._warn_on_deprecated_slot_setter = true
|
31
|
+
end
|
32
|
+
|
23
33
|
##
|
24
34
|
# Registers a sub-component
|
25
35
|
#
|
@@ -61,20 +71,34 @@ module ViewComponent
|
|
61
71
|
# = Setting sub-component content
|
62
72
|
#
|
63
73
|
# Consumers of the component can render a sub-component by calling a
|
64
|
-
# helper method with the same name as the slot
|
74
|
+
# helper method with the same name as the slot prefixed with `with_`.
|
65
75
|
#
|
66
76
|
# <%= render_inline(MyComponent.new) do |component| %>
|
67
|
-
# <% component.
|
77
|
+
# <% component.with_header(classes: "Foo") do %>
|
68
78
|
# <p>Bar</p>
|
69
79
|
# <% end %>
|
70
80
|
# <% end %>
|
71
81
|
def renders_one(slot_name, callable = nil)
|
72
82
|
validate_singular_slot_name(slot_name)
|
83
|
+
validate_plural_slot_name(ActiveSupport::Inflector.pluralize(slot_name).to_sym)
|
84
|
+
|
85
|
+
define_method :"with_#{slot_name}" do |*args, &block|
|
86
|
+
set_slot(slot_name, nil, *args, &block)
|
87
|
+
end
|
88
|
+
ruby2_keywords(:"with_#{slot_name}") if respond_to?(:ruby2_keywords, true)
|
73
89
|
|
74
90
|
define_method slot_name do |*args, &block|
|
75
91
|
if args.empty? && block.nil?
|
76
92
|
get_slot(slot_name)
|
77
93
|
else
|
94
|
+
if _warn_on_deprecated_slot_setter
|
95
|
+
stack = caller_locations(3)
|
96
|
+
msg = "Setting a slot with `##{slot_name}` is deprecated and will be removed in ViewComponent v3.0.0. " \
|
97
|
+
"Use `#with_#{slot_name}` to set the slot instead."
|
98
|
+
|
99
|
+
ViewComponent::Deprecation.warn(msg, stack)
|
100
|
+
end
|
101
|
+
|
78
102
|
set_slot(slot_name, nil, *args, &block)
|
79
103
|
end
|
80
104
|
end
|
@@ -92,11 +116,11 @@ module ViewComponent
|
|
92
116
|
#
|
93
117
|
# = Example
|
94
118
|
#
|
95
|
-
#
|
119
|
+
# renders_many :items, -> (name:) { ItemComponent.new(name: name }
|
96
120
|
#
|
97
121
|
# # OR
|
98
122
|
#
|
99
|
-
#
|
123
|
+
# renders_many :items, ItemComponent
|
100
124
|
#
|
101
125
|
# = Rendering sub-components
|
102
126
|
#
|
@@ -112,37 +136,63 @@ module ViewComponent
|
|
112
136
|
# = Setting sub-component content
|
113
137
|
#
|
114
138
|
# Consumers of the component can set the content of a slot by calling a
|
115
|
-
# helper method with the same name as the slot
|
116
|
-
# called multiple times to append to the slot.
|
139
|
+
# helper method with the same name as the slot prefixed with `with_`. The
|
140
|
+
# method can be called multiple times to append to the slot.
|
117
141
|
#
|
118
142
|
# <%= render_inline(MyComponent.new) do |component| %>
|
119
|
-
# <% component.
|
143
|
+
# <% component.with_item(name: "Foo") do %>
|
120
144
|
# <p>One</p>
|
121
145
|
# <% end %>
|
122
146
|
#
|
123
|
-
# <% component.
|
147
|
+
# <% component.with_item(name: "Bar") do %>
|
124
148
|
# <p>two</p>
|
125
149
|
# <% end %>
|
126
150
|
# <% end %>
|
127
151
|
def renders_many(slot_name, callable = nil)
|
128
|
-
validate_plural_slot_name(slot_name)
|
129
|
-
|
130
152
|
singular_name = ActiveSupport::Inflector.singularize(slot_name)
|
153
|
+
validate_plural_slot_name(slot_name)
|
154
|
+
validate_singular_slot_name(ActiveSupport::Inflector.singularize(slot_name).to_sym)
|
131
155
|
|
132
156
|
# Define setter for singular names
|
133
157
|
# for example `renders_many :items` allows fetching all tabs with
|
134
158
|
# `component.tabs` and setting a tab with `component.tab`
|
159
|
+
|
135
160
|
define_method singular_name do |*args, &block|
|
161
|
+
if _warn_on_deprecated_slot_setter
|
162
|
+
ViewComponent::Deprecation.warn(
|
163
|
+
"Setting a slot with `##{singular_name}` is deprecated and will be removed in ViewComponent v3.0.0. " \
|
164
|
+
"Use `#with_#{singular_name}` to set the slot instead."
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
136
168
|
set_slot(slot_name, nil, *args, &block)
|
137
169
|
end
|
138
170
|
ruby2_keywords(singular_name.to_sym) if respond_to?(:ruby2_keywords, true)
|
139
171
|
|
172
|
+
define_method :"with_#{singular_name}" do |*args, &block|
|
173
|
+
set_slot(slot_name, nil, *args, &block)
|
174
|
+
end
|
175
|
+
ruby2_keywords(:"with_#{singular_name}") if respond_to?(:ruby2_keywords, true)
|
176
|
+
|
177
|
+
define_method :"with_#{slot_name}" do |collection_args = nil, &block|
|
178
|
+
collection_args.map do |args|
|
179
|
+
set_slot(slot_name, nil, **args, &block)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
140
183
|
# Instantiates and and adds multiple slots forwarding the first
|
141
184
|
# argument to each slot constructor
|
142
185
|
define_method slot_name do |collection_args = nil, &block|
|
143
186
|
if collection_args.nil? && block.nil?
|
144
187
|
get_slot(slot_name)
|
145
188
|
else
|
189
|
+
if _warn_on_deprecated_slot_setter
|
190
|
+
ViewComponent::Deprecation.warn(
|
191
|
+
"Setting a slot with `##{slot_name}` is deprecated and will be removed in ViewComponent v3.0.0. " \
|
192
|
+
"Use `#with_#{slot_name}` to set the slot instead."
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
146
196
|
collection_args.map do |args|
|
147
197
|
set_slot(slot_name, nil, **args, &block)
|
148
198
|
end
|
@@ -170,20 +220,20 @@ module ViewComponent
|
|
170
220
|
# Clone slot configuration into child class
|
171
221
|
# see #test_slots_pollution
|
172
222
|
def inherited(child)
|
173
|
-
child.registered_slots =
|
223
|
+
child.registered_slots = registered_slots.clone
|
174
224
|
super
|
175
225
|
end
|
176
226
|
|
177
227
|
private
|
178
228
|
|
179
229
|
def register_slot(slot_name, **kwargs)
|
180
|
-
|
230
|
+
registered_slots[slot_name] = define_slot(slot_name, **kwargs)
|
181
231
|
end
|
182
232
|
|
183
233
|
def define_slot(slot_name, collection:, callable:)
|
184
234
|
# Setup basic slot data
|
185
235
|
slot = {
|
186
|
-
collection: collection
|
236
|
+
collection: collection
|
187
237
|
}
|
188
238
|
return slot unless callable
|
189
239
|
|
@@ -234,7 +284,7 @@ module ViewComponent
|
|
234
284
|
end
|
235
285
|
|
236
286
|
def raise_if_slot_registered(slot_name)
|
237
|
-
if
|
287
|
+
if registered_slots.key?(slot_name)
|
238
288
|
# TODO remove? This breaks overriding slots when slots are inherited
|
239
289
|
raise ArgumentError.new(
|
240
290
|
"#{self} declares the #{slot_name} slot multiple times.\n\n" \
|
@@ -246,8 +296,8 @@ module ViewComponent
|
|
246
296
|
def raise_if_slot_ends_with_question_mark(slot_name)
|
247
297
|
if slot_name.to_s.ends_with?("?")
|
248
298
|
raise ArgumentError.new(
|
249
|
-
"#{self} declares a slot named #{slot_name}, which ends with a question mark.\n\n"\
|
250
|
-
"This is not allowed because the ViewComponent framework already provides predicate "\
|
299
|
+
"#{self} declares a slot named #{slot_name}, which ends with a question mark.\n\n" \
|
300
|
+
"This is not allowed because the ViewComponent framework already provides predicate " \
|
251
301
|
"methods ending in `?`.\n\n" \
|
252
302
|
"To fix this issue, choose a different name."
|
253
303
|
)
|
@@ -267,8 +317,6 @@ module ViewComponent
|
|
267
317
|
|
268
318
|
if slot[:collection]
|
269
319
|
[]
|
270
|
-
else
|
271
|
-
nil
|
272
320
|
end
|
273
321
|
end
|
274
322
|
|
@@ -285,7 +333,7 @@ module ViewComponent
|
|
285
333
|
# 2. Since we've to pass block content to components when calling
|
286
334
|
# `render`, evaluating the block here would require us to call
|
287
335
|
# `view_context.capture` twice, which is slower
|
288
|
-
slot.__vc_content_block = block if
|
336
|
+
slot.__vc_content_block = block if block
|
289
337
|
|
290
338
|
# If class
|
291
339
|
if slot_definition[:renderable]
|
@@ -301,7 +349,7 @@ module ViewComponent
|
|
301
349
|
# methods like `content_tag` as well as parent component state.
|
302
350
|
renderable_function = slot_definition[:renderable_function].bind(self)
|
303
351
|
renderable_value =
|
304
|
-
if
|
352
|
+
if block
|
305
353
|
renderable_function.call(*args) do |*rargs|
|
306
354
|
view_context.capture(*rargs, &block)
|
307
355
|
end
|
@@ -4,10 +4,11 @@ module ViewComponent
|
|
4
4
|
module TestHelpers
|
5
5
|
begin
|
6
6
|
require "capybara/minitest"
|
7
|
+
|
7
8
|
include Capybara::Minitest::Assertions
|
8
9
|
|
9
10
|
def page
|
10
|
-
Capybara::Node::Simple.new(
|
11
|
+
@page ||= Capybara::Node::Simple.new(rendered_content)
|
11
12
|
end
|
12
13
|
|
13
14
|
def refute_component_rendered
|
@@ -19,8 +20,8 @@ module ViewComponent
|
|
19
20
|
# :nocov:
|
20
21
|
if ENV["DEBUG"]
|
21
22
|
warn(
|
22
|
-
"WARNING in `ViewComponent::TestHelpers`:
|
23
|
-
"to
|
23
|
+
"WARNING in `ViewComponent::TestHelpers`: Add `capybara` " \
|
24
|
+
"to Gemfile to use Capybara assertions."
|
24
25
|
)
|
25
26
|
end
|
26
27
|
|
@@ -28,7 +29,19 @@ module ViewComponent
|
|
28
29
|
end
|
29
30
|
|
30
31
|
# @private
|
31
|
-
attr_reader :
|
32
|
+
attr_reader :rendered_content
|
33
|
+
|
34
|
+
# Returns the result of a render_inline call.
|
35
|
+
#
|
36
|
+
# @return [String]
|
37
|
+
def rendered_component
|
38
|
+
ViewComponent::Deprecation.warn(
|
39
|
+
"`rendered_component` is deprecated and will be removed in v3.0.0. " \
|
40
|
+
"Use `page` instead."
|
41
|
+
)
|
42
|
+
|
43
|
+
rendered_content
|
44
|
+
end
|
32
45
|
|
33
46
|
# Render a component inline. Internally sets `page` to be a `Capybara::Node::Simple`,
|
34
47
|
# allowing for Capybara assertions to be used:
|
@@ -41,14 +54,72 @@ module ViewComponent
|
|
41
54
|
# @param component [ViewComponent::Base, ViewComponent::Collection] The instance of the component to be rendered.
|
42
55
|
# @return [Nokogiri::HTML]
|
43
56
|
def render_inline(component, **args, &block)
|
44
|
-
@
|
57
|
+
@page = nil
|
58
|
+
@rendered_content =
|
45
59
|
if Rails.version.to_f >= 6.1
|
46
60
|
controller.view_context.render(component, args, &block)
|
47
61
|
else
|
48
62
|
controller.view_context.render_component(component, &block)
|
49
63
|
end
|
50
64
|
|
51
|
-
Nokogiri::HTML.fragment(@
|
65
|
+
Nokogiri::HTML.fragment(@rendered_content)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Render a preview inline. Internally sets `page` to be a `Capybara::Node::Simple`,
|
69
|
+
# allowing for Capybara assertions to be used:
|
70
|
+
#
|
71
|
+
# ```ruby
|
72
|
+
# render_preview(:default)
|
73
|
+
# assert_text("Hello, World!")
|
74
|
+
# ```
|
75
|
+
#
|
76
|
+
# Note: `#rendered_preview` expects a preview to be defined with the same class
|
77
|
+
# name as the calling test, but with `Test` replaced with `Preview`:
|
78
|
+
#
|
79
|
+
# MyComponentTest -> MyComponentPreview etc.
|
80
|
+
#
|
81
|
+
# In RSpec, `Preview` is appended to `described_class`.
|
82
|
+
#
|
83
|
+
# @param preview [String] The name of the preview to be rendered.
|
84
|
+
# @return [Nokogiri::HTML]
|
85
|
+
def render_preview(name)
|
86
|
+
begin
|
87
|
+
preview_klass = if respond_to?(:described_class)
|
88
|
+
raise "`render_preview` expected a described_class, but it is nil." if described_class.nil?
|
89
|
+
|
90
|
+
"#{described_class}Preview"
|
91
|
+
else
|
92
|
+
self.class.name.gsub("Test", "Preview")
|
93
|
+
end
|
94
|
+
preview_klass = preview_klass.constantize
|
95
|
+
rescue NameError
|
96
|
+
raise NameError, "`render_preview` expected to find #{preview_klass}, but it does not exist."
|
97
|
+
end
|
98
|
+
|
99
|
+
previews_controller = build_controller(Rails.application.config.view_component.preview_controller.constantize)
|
100
|
+
previews_controller.request.params[:path] = "#{preview_klass.preview_name}/#{name}"
|
101
|
+
previews_controller.response = ActionDispatch::Response.new
|
102
|
+
result = previews_controller.previews
|
103
|
+
|
104
|
+
@rendered_content = result
|
105
|
+
|
106
|
+
Nokogiri::HTML.fragment(@rendered_content)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Execute the given block in the view context. Internally sets `page` to be a
|
110
|
+
# `Capybara::Node::Simple`, allowing for Capybara assertions to be used:
|
111
|
+
#
|
112
|
+
# ```ruby
|
113
|
+
# render_in_view_context do
|
114
|
+
# render(MyComponent.new)
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# assert_text("Hello, World!")
|
118
|
+
# ```
|
119
|
+
def render_in_view_context(&block)
|
120
|
+
@page = nil
|
121
|
+
@rendered_content = controller.view_context.instance_exec(&block)
|
122
|
+
Nokogiri::HTML.fragment(@rendered_content)
|
52
123
|
end
|
53
124
|
|
54
125
|
# @private
|
@@ -119,10 +190,11 @@ module ViewComponent
|
|
119
190
|
old_request_query_string = request.query_string
|
120
191
|
old_controller = defined?(@controller) && @controller
|
121
192
|
|
193
|
+
path, query = path.split("?", 2)
|
122
194
|
request.path_info = path
|
123
195
|
request.path_parameters = Rails.application.routes.recognize_path(path)
|
124
|
-
request.set_header("action_dispatch.request.query_parameters", Rack::Utils.
|
125
|
-
request.set_header(Rack::QUERY_STRING,
|
196
|
+
request.set_header("action_dispatch.request.query_parameters", Rack::Utils.parse_nested_query(query))
|
197
|
+
request.set_header(Rack::QUERY_STRING, query)
|
126
198
|
yield
|
127
199
|
ensure
|
128
200
|
request.path_info = old_request_path_info
|
@@ -3,14 +3,13 @@
|
|
3
3
|
require "erb"
|
4
4
|
require "set"
|
5
5
|
require "i18n"
|
6
|
-
require "action_view/helpers/translation_helper"
|
7
6
|
require "active_support/concern"
|
8
7
|
|
9
8
|
module ViewComponent
|
10
9
|
module Translatable
|
11
10
|
extend ActiveSupport::Concern
|
12
11
|
|
13
|
-
HTML_SAFE_TRANSLATION_KEY = /(?:_|\b)html\z
|
12
|
+
HTML_SAFE_TRANSLATION_KEY = /(?:_|\b)html\z/
|
14
13
|
|
15
14
|
included do
|
16
15
|
class_attribute :i18n_backend, instance_writer: false, instance_predicate: false
|
@@ -21,19 +20,16 @@ module ViewComponent
|
|
21
20
|
@i18n_scope ||= virtual_path.sub(%r{^/}, "").gsub(%r{/_?}, ".")
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
super
|
26
|
-
|
23
|
+
def build_i18n_backend
|
27
24
|
return if CompileCache.compiled? self
|
28
25
|
|
29
|
-
if (translation_files = _sidecar_files(%w[yml yaml])).any?
|
30
|
-
|
26
|
+
self.i18n_backend = if (translation_files = _sidecar_files(%w[yml yaml])).any?
|
27
|
+
# Returning nil cleans up if translations file has been removed since the last compilation
|
28
|
+
|
29
|
+
I18nBackend.new(
|
31
30
|
i18n_scope: i18n_scope,
|
32
|
-
load_paths: translation_files
|
31
|
+
load_paths: translation_files
|
33
32
|
)
|
34
|
-
else
|
35
|
-
# Cleanup if translations file has been removed since the last compilation
|
36
|
-
self.i18n_backend = nil
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -53,7 +49,7 @@ module ViewComponent
|
|
53
49
|
|
54
50
|
def scope_data(data)
|
55
51
|
@i18n_scope.reverse_each do |part|
|
56
|
-
data = {
|
52
|
+
data = {part => data}
|
57
53
|
end
|
58
54
|
data
|
59
55
|
end
|
@@ -68,7 +64,10 @@ module ViewComponent
|
|
68
64
|
return key.map { |k| translate(k, **options) } if key.is_a?(Array)
|
69
65
|
|
70
66
|
locale = options.delete(:locale) || ::I18n.locale
|
67
|
+
scope = options.delete(:scope)
|
68
|
+
scope = scope.join(".") if scope.is_a? Array
|
71
69
|
key = key&.to_s unless key.is_a?(String)
|
70
|
+
key = "#{scope}.#{key}" if scope
|
72
71
|
key = "#{i18n_scope}#{key}" if key.start_with?(".")
|
73
72
|
|
74
73
|
if HTML_SAFE_TRANSLATION_KEY.match?(key)
|
@@ -95,7 +94,7 @@ module ViewComponent
|
|
95
94
|
super(key, locale: locale, **options)
|
96
95
|
end
|
97
96
|
end
|
98
|
-
|
97
|
+
alias_method :t, :translate
|
99
98
|
|
100
99
|
# Exposes .i18n_scope as an instance method
|
101
100
|
def i18n_scope
|
@@ -109,7 +108,7 @@ module ViewComponent
|
|
109
108
|
# It's assumed here that objects loaded by the i18n backend will respond to `#html_safe?`.
|
110
109
|
# It's reasonable that if we're in Rails, `active_support/core_ext/string/output_safety.rb`
|
111
110
|
# will provide this to `Object`.
|
112
|
-
translation.html_safe
|
111
|
+
translation.html_safe
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
data/lib/view_component.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.69.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- ViewComponent Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: concurrent-ruby
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: appraisal
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,16 +104,16 @@ dependencies:
|
|
90
104
|
name: bundler
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
|
-
- - "
|
107
|
+
- - "~>"
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
109
|
+
version: '2'
|
96
110
|
type: :development
|
97
111
|
prerelease: false
|
98
112
|
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
|
-
- - "
|
114
|
+
- - "~>"
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
116
|
+
version: '2'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
118
|
name: erb_lint
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +156,20 @@ dependencies:
|
|
142
156
|
- - "~>"
|
143
157
|
- !ruby/object:Gem::Version
|
144
158
|
version: '2'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: m
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '1'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '1'
|
145
173
|
- !ruby/object:Gem::Dependency
|
146
174
|
name: minitest
|
147
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,19 +213,19 @@ dependencies:
|
|
185
213
|
- !ruby/object:Gem::Version
|
186
214
|
version: '13.0'
|
187
215
|
- !ruby/object:Gem::Dependency
|
188
|
-
name:
|
216
|
+
name: standard
|
189
217
|
requirement: !ruby/object:Gem::Requirement
|
190
218
|
requirements:
|
191
219
|
- - "~>"
|
192
220
|
- !ruby/object:Gem::Version
|
193
|
-
version:
|
221
|
+
version: '1'
|
194
222
|
type: :development
|
195
223
|
prerelease: false
|
196
224
|
version_requirements: !ruby/object:Gem::Requirement
|
197
225
|
requirements:
|
198
226
|
- - "~>"
|
199
227
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
228
|
+
version: '1'
|
201
229
|
- !ruby/object:Gem::Dependency
|
202
230
|
name: simplecov
|
203
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -272,19 +300,18 @@ dependencies:
|
|
272
300
|
name: yard-activesupport-concern
|
273
301
|
requirement: !ruby/object:Gem::Requirement
|
274
302
|
requirements:
|
275
|
-
- - "
|
303
|
+
- - "~>"
|
276
304
|
- !ruby/object:Gem::Version
|
277
|
-
version:
|
305
|
+
version: 0.0.1
|
278
306
|
type: :development
|
279
307
|
prerelease: false
|
280
308
|
version_requirements: !ruby/object:Gem::Requirement
|
281
309
|
requirements:
|
282
|
-
- - "
|
310
|
+
- - "~>"
|
283
311
|
- !ruby/object:Gem::Version
|
284
|
-
version:
|
312
|
+
version: 0.0.1
|
285
313
|
description:
|
286
314
|
email:
|
287
|
-
- opensource+view_component@github.com
|
288
315
|
executables: []
|
289
316
|
extensions: []
|
290
317
|
extra_rdoc_files: []
|
@@ -293,6 +320,7 @@ files:
|
|
293
320
|
- README.md
|
294
321
|
- app/assets/vendor/prism.css
|
295
322
|
- app/assets/vendor/prism.min.js
|
323
|
+
- app/controllers/concerns/view_component/preview_actions.rb
|
296
324
|
- app/controllers/view_components_controller.rb
|
297
325
|
- app/helpers/preview_helper.rb
|
298
326
|
- app/views/test_mailer/test_email.html.erb
|
@@ -328,6 +356,7 @@ files:
|
|
328
356
|
- lib/view_component/compile_cache.rb
|
329
357
|
- lib/view_component/compiler.rb
|
330
358
|
- lib/view_component/component_error.rb
|
359
|
+
- lib/view_component/config.rb
|
331
360
|
- lib/view_component/content_areas.rb
|
332
361
|
- lib/view_component/deprecation.rb
|
333
362
|
- lib/view_component/docs_builder_component.html.erb
|
@@ -337,7 +366,6 @@ files:
|
|
337
366
|
- lib/view_component/polymorphic_slots.rb
|
338
367
|
- lib/view_component/preview.rb
|
339
368
|
- lib/view_component/preview_template_error.rb
|
340
|
-
- lib/view_component/previewable.rb
|
341
369
|
- lib/view_component/rails/tasks/view_component.rake
|
342
370
|
- lib/view_component/render_component_helper.rb
|
343
371
|
- lib/view_component/render_component_to_string_helper.rb
|
@@ -356,7 +384,7 @@ files:
|
|
356
384
|
- lib/view_component/version.rb
|
357
385
|
- lib/view_component/with_content_helper.rb
|
358
386
|
- lib/yard/mattr_accessor_handler.rb
|
359
|
-
homepage: https://
|
387
|
+
homepage: https://viewcomponent.org
|
360
388
|
licenses:
|
361
389
|
- MIT
|
362
390
|
metadata:
|
@@ -379,5 +407,6 @@ requirements: []
|
|
379
407
|
rubygems_version: 3.2.32
|
380
408
|
signing_key:
|
381
409
|
specification_version: 4
|
382
|
-
summary:
|
410
|
+
summary: A framework for building reusable, testable & encapsulated view components
|
411
|
+
in Ruby on Rails.
|
383
412
|
test_files: []
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "active_support/concern"
|
4
|
-
|
5
|
-
module ViewComponent
|
6
|
-
module Previewable
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
# Enable or disable component previews:
|
11
|
-
#
|
12
|
-
# config.view_component.show_previews = true
|
13
|
-
#
|
14
|
-
# Defaults to `true` in development.
|
15
|
-
#
|
16
|
-
mattr_accessor :show_previews, instance_writer: false
|
17
|
-
|
18
|
-
# Enable or disable source code previews in component previews:
|
19
|
-
#
|
20
|
-
# config.view_component.show_previews_source = true
|
21
|
-
#
|
22
|
-
# Defaults to `false`.
|
23
|
-
#
|
24
|
-
mattr_accessor :show_previews_source, instance_writer: false, default: false
|
25
|
-
|
26
|
-
# Set a custom default layout used for preview index and individual previews:
|
27
|
-
#
|
28
|
-
# config.view_component.default_preview_layout = "component_preview"
|
29
|
-
#
|
30
|
-
mattr_accessor :default_preview_layout, instance_writer: false
|
31
|
-
|
32
|
-
# Set the location of component previews:
|
33
|
-
#
|
34
|
-
# config.view_component.preview_paths << "#{Rails.root}/lib/component_previews"
|
35
|
-
#
|
36
|
-
mattr_accessor :preview_paths, instance_writer: false
|
37
|
-
|
38
|
-
# @deprecated Use `preview_paths` instead. Will be removed in v3.0.0.
|
39
|
-
mattr_accessor :preview_path, instance_writer: false
|
40
|
-
|
41
|
-
# Set the entry route for component previews:
|
42
|
-
#
|
43
|
-
# config.view_component.preview_route = "/previews"
|
44
|
-
#
|
45
|
-
# Defaults to `/rails/view_components` when `show_previews` is enabled.
|
46
|
-
#
|
47
|
-
mattr_accessor :preview_route, instance_writer: false do
|
48
|
-
"/rails/view_components"
|
49
|
-
end
|
50
|
-
|
51
|
-
# Set the controller used for previewing components:
|
52
|
-
#
|
53
|
-
# config.view_component.preview_controller = "MyPreviewController"
|
54
|
-
#
|
55
|
-
# Defaults to `ViewComponentsController`.
|
56
|
-
#
|
57
|
-
mattr_accessor :preview_controller, instance_writer: false do
|
58
|
-
"ViewComponentsController"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|