@@ -199,11 +199,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
199199 }
200200
201201 // 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 );
207203
208204 // Save current vars
209205 $ renderVars = $ this ->renderVars ;
@@ -275,13 +271,9 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
275271 */
276272 public function renderString (string $ view , ?array $ options = null , ?bool $ saveData = null ): string
277273 {
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 );
285277
286278 $ output = (function (string $ view ): string {
287279 extract ($ this ->tempData );
@@ -454,4 +446,13 @@ protected function logPerformance(float $start, float $end, string $view)
454446 ];
455447 }
456448 }
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+ }
457458}
0 commit comments