-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from inertiajs/deep-merge-shared-props
Deep merge props passed to render method with the shared data
- Loading branch information
Showing
10 changed files
with
201 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
spec/dummy/app/controllers/inertia_merge_instance_props_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class InertiaMergeInstancePropsController < ApplicationController | ||
use_inertia_instance_props | ||
inertia_share do | ||
{ | ||
nested: { | ||
points: 55, | ||
rebounds: 10, | ||
} | ||
} | ||
end | ||
|
||
def merge_instance_props | ||
@nested = { | ||
points: 100, | ||
} | ||
|
||
render inertia: 'InertiaTestComponent', deep_merge: true | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
spec/dummy/app/controllers/inertia_merge_shared_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class InertiaMergeSharedController < ApplicationController | ||
inertia_share do | ||
{ | ||
nested: { | ||
goals: 100, | ||
assists: 100, | ||
} | ||
} | ||
end | ||
|
||
def merge_shared | ||
render inertia: 'ShareTestComponent', props: { | ||
nested: { | ||
assists: 200, | ||
} | ||
} | ||
end | ||
|
||
def deep_merge_shared | ||
render inertia: 'ShareTestComponent', props: { | ||
nested: { | ||
assists: 300, | ||
} | ||
}, deep_merge: true | ||
end | ||
|
||
def shallow_merge_shared | ||
render inertia: 'ShareTestComponent', props: { | ||
nested: { | ||
assists: 200, | ||
} | ||
}, deep_merge: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters