@@ -199,11 +199,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
199
199
}
200
200
201
201
// Make our view data available to the view.
202
- $ this ->tempData = $ this ->tempData ?? $ this ->data ;
203
-
204
- if ($ saveData ) {
205
- $ this ->data = $ this ->tempData ;
206
- }
202
+ $ this ->prepareTemplateData ($ saveData );
207
203
208
204
// Save current vars
209
205
$ renderVars = $ this ->renderVars ;
@@ -275,13 +271,9 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
275
271
*/
276
272
public function renderString (string $ view , ?array $ options = null , ?bool $ saveData = null ): string
277
273
{
278
- $ start = microtime (true );
279
- $ saveData = $ saveData ?? $ this ->saveData ;
280
- $ this ->tempData = $ this ->tempData ?? $ this ->data ;
281
-
282
- if ($ saveData ) {
283
- $ this ->data = $ this ->tempData ;
284
- }
274
+ $ start = microtime (true );
275
+ $ saveData = $ saveData ?? $ this ->saveData ;
276
+ $ this ->prepareTemplateData ($ saveData );
285
277
286
278
$ output = (function (string $ view ): string {
287
279
extract ($ this ->tempData );
@@ -454,4 +446,13 @@ protected function logPerformance(float $start, float $end, string $view)
454
446
];
455
447
}
456
448
}
449
+
450
+ protected function prepareTemplateData (bool $ saveData ): void
451
+ {
452
+ $ this ->tempData = $ this ->tempData ?? $ this ->data ;
453
+
454
+ if ($ saveData ) {
455
+ $ this ->data = $ this ->tempData ;
456
+ }
457
+ }
457
458
}
0 commit comments