/** * Get the string contents of the view. * * @param \Closure|null $callback * @return string */ public function render(Closure $callback = null) { $contents = $this->renderContents(); $response = isset($callback) ? $callback($this, $contents) : null; // Once we have the contents of the view, we will flush the sections if we are // done rendering all views so that there is nothing left hanging over when // another view gets rendered in the future by the application developer. $this->factory->flushSectionsIfDoneRendering(); return $response ?: $contents; }
/** * Get the string contents of the view. * * @param callable|null $callback * @return string */ public function render(callable $callback = null) { try { $contents = $this->renderContents(); $response = isset($callback) ? call_user_func($callback, $this, $contents) : null; // Once we have the contents of the view, we will flush the sections if we are // done rendering all views so that there is nothing left hanging over when // another view gets rendered in the future by the application developer. $this->factory->flushSectionsIfDoneRendering(); return !is_null($response) ? $response : $contents; } catch (Exception $e) { $this->factory->flushSections(); throw $e; } }
/** * Flush all of the section contents if done rendering. * * @return void * @static */ public static function flushSectionsIfDoneRendering() { \Illuminate\View\Factory::flushSectionsIfDoneRendering(); }