Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhawksley authored Oct 7, 2024
2 parents 9054cf9 + f4b5e18 commit 1eb5015
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ GEM
rake
thor (>= 0.14.0)
ast (2.4.2)
base64 (0.2.0)
benchmark-ips (2.13.0)
better_html (2.1.1)
actionview (>= 6.0)
Expand All @@ -91,6 +92,7 @@ GEM
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.8)
builder (3.3.0)
capybara (3.40.0)
addressable
Expand All @@ -113,6 +115,7 @@ GEM
reline (>= 0.3.8)
diff-lcs (1.5.1)
docile (1.4.1)
drb (2.2.1)
erb_lint (0.6.0)
activesupport
better_html (>= 2.0.1)
Expand Down Expand Up @@ -161,6 +164,7 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
mutex_m (0.2.0)
net-imap (0.4.16)
date
net-protocol
Expand Down Expand Up @@ -334,17 +338,21 @@ PLATFORMS
DEPENDENCIES
allocation_stats (~> 0.1.5)
appraisal (~> 2.4)
base64
benchmark-ips (~> 2.13.0)
better_html
bigdecimal
bundler (~> 2)
capybara (~> 3)
cuprite (~> 0.15)
debug
drb
erb_lint
haml (~> 6)
jbuilder (~> 2)
m (~> 1)
minitest (~> 5.18)
mutex_m
net-imap
net-pop
net-smtp
Expand Down
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ nav_order: 5

*Chloe Fons*

* Use struct instead openstruct in lib code.

*Oleksii Vasyliev*

* Fix bug where stimulus controller was not added to ERB when stimulus was activated by default.

*Denis Pasin*
Expand All @@ -22,6 +26,10 @@ nav_order: 5

*Denis Pasin*

* Fix the example of #vc_test_request in the API reference to use the correct method name.

*Alberto Rocha*

## 3.16.0

* Add template information to multiple template error messages.
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Access the request used by `render_inline`:

```ruby
test "component does not render in Firefox" do
request.env["HTTP_USER_AGENT"] = "Mozilla/5.0"
vc_test_request.env["HTTP_USER_AGENT"] = "Mozilla/5.0"
render_inline(NoFirefoxComponent.new)
refute_component_rendered
end
Expand Down
9 changes: 6 additions & 3 deletions lib/view_component/template.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require "ostruct"
# frozen_string_literal: true

module ViewComponent
class Template
DataWithSource = Struct.new(:format, :identifier, :short_identifier, :type, keyword_init: true)
DataNoSource = Struct.new(:source, :identifier, :type, keyword_init: true)

attr_reader :variant, :this_format, :type

def initialize(
Expand Down Expand Up @@ -113,13 +116,13 @@ def compiled_source

if handler.method(:call).parameters.length > 1
handler.call(
OpenStruct.new(format: @this_format, identifier: @path, short_identifier: short_identifier, type: type),
DataWithSource.new(format: @this_format, identifier: @path, short_identifier: short_identifier, type: type),
this_source
)
# :nocov:
# TODO: Remove in v4
else
handler.call(OpenStruct.new(source: this_source, identifier: @path, type: type))
handler.call(DataNoSource.new(source: this_source, identifier: @path, type: type))
end
# :nocov:
end
Expand Down
2 changes: 2 additions & 0 deletions test/sandbox/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

require "ostruct"

class ApplicationController < ActionController::Base
end
4 changes: 4 additions & 0 deletions view_component.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Gem::Specification.new do |spec|
end

if RUBY_VERSION >= "3.3"
spec.add_development_dependency "base64"
spec.add_development_dependency "bigdecimal"
spec.add_development_dependency "drb"
spec.add_development_dependency "mutex_m"
spec.add_development_dependency "ostruct"
end
end

0 comments on commit 1eb5015

Please sign in to comment.