@@ -91,14 +91,16 @@ public function fragment($fragment)
91
91
}
92
92
93
93
/**
94
- * Get the evaluated contents for a given array of fragments.
94
+ * Get the evaluated contents for a given array of fragments or return all fragments .
95
95
*
96
- * @param array $fragments
96
+ * @param array|null $fragments
97
97
* @return string
98
98
*/
99
- public function fragments (array $ fragments )
99
+ public function fragments (? array $ fragments = null )
100
100
{
101
- return collect ($ fragments )->map (fn ($ f ) => $ this ->fragment ($ f ))->implode ('' );
101
+ return is_null ($ fragments )
102
+ ? $ this ->allFragments ()
103
+ : collect ($ fragments )->map (fn ($ f ) => $ this ->fragment ($ f ))->implode ('' );
102
104
}
103
105
104
106
/**
@@ -121,10 +123,10 @@ public function fragmentIf($boolean, $fragment)
121
123
* Get the evaluated contents for a given array of fragments if the given condition is true.
122
124
*
123
125
* @param bool $boolean
124
- * @param array $fragments
126
+ * @param array|null $fragments
125
127
* @return string
126
128
*/
127
- public function fragmentsIf ($ boolean , array $ fragments )
129
+ public function fragmentsIf ($ boolean , ? array $ fragments = null )
128
130
{
129
131
if (value ($ boolean )) {
130
132
return $ this ->fragments ($ fragments );
@@ -133,6 +135,16 @@ public function fragmentsIf($boolean, array $fragments)
133
135
return $ this ->render ();
134
136
}
135
137
138
+ /**
139
+ * Get all fragments as a single string.
140
+ *
141
+ * @return string
142
+ */
143
+ protected function allFragments ()
144
+ {
145
+ return collect ($ this ->render (fn () => $ this ->factory ->getFragments ()))->implode ('' );
146
+ }
147
+
136
148
/**
137
149
* Get the string contents of the view.
138
150
*
0 commit comments