File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -66,11 +66,18 @@ public function resolveView()
66
66
return $ view ;
67
67
}
68
68
69
- $ factory = Container::getInstance ()->make ('view ' );
69
+ $ resolver = function ($ view ) {
70
+ $ factory = Container::getInstance ()->make ('view ' );
70
71
71
- return $ factory ->exists ($ view )
72
- ? $ view
73
- : $ this ->createBladeViewFromString ($ factory , $ view );
72
+ return $ factory ->exists ($ view )
73
+ ? $ view
74
+ : $ this ->createBladeViewFromString ($ factory , $ view );
75
+ };
76
+
77
+ return $ view instanceof Closure ? function (array $ data = []) use ($ view , $ resolver ) {
78
+ return $ resolver ($ view ($ data ));
79
+ }
80
+ : $ resolver ($ view );
74
81
}
75
82
76
83
/**
Original file line number Diff line number Diff line change 2
2
3
3
namespace Illuminate \View \Concerns ;
4
4
5
+ use Closure ;
5
6
use Illuminate \Support \Arr ;
6
7
use Illuminate \Support \HtmlString ;
7
8
use Illuminate \View \View ;
@@ -40,7 +41,7 @@ trait ManagesComponents
40
41
/**
41
42
* Start a component rendering process.
42
43
*
43
- * @param \Illuminate\View\View|string $view
44
+ * @param \Illuminate\View\View|\Closure| string $view
44
45
* @param array $data
45
46
* @return void
46
47
*/
@@ -80,10 +81,16 @@ public function renderComponent()
80
81
{
81
82
$ view = array_pop ($ this ->componentStack );
82
83
84
+ $ data = $ this ->componentData ();
85
+
86
+ if ($ view instanceof Closure) {
87
+ $ view = $ view ($ data );
88
+ }
89
+
83
90
if ($ view instanceof View) {
84
- return $ view ->with ($ this -> componentData () )->render ();
91
+ return $ view ->with ($ data )->render ();
85
92
} else {
86
- return $ this ->make ($ view , $ this -> componentData () )->render ();
93
+ return $ this ->make ($ view , $ data )->render ();
87
94
}
88
95
}
89
96
You can’t perform that action at this time.
0 commit comments