Skip to content

Commit 6e25044

Browse files
committed
feat: add response::view function to render configured views
1 parent 1f722e3 commit 6e25044

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Response.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,33 @@ public function noContent()
232232
$this->send();
233233
}
234234

235+
/**
236+
* Render a view file if a view engine is available
237+
*
238+
* @param string $view The view file to render
239+
* @param array $data The data to pass to the view
240+
*/
241+
public function view(string $view, array $data = [])
242+
{
243+
if (!function_exists('view')) {
244+
$this->markup(
245+
view($view, $data),
246+
);
247+
}
248+
249+
if (app()->blade()) {
250+
$this->markup(
251+
app()->blade()->render($view, $data),
252+
);
253+
}
254+
255+
if (app()->template()) {
256+
$this->markup(
257+
app()->template()->render($view, $data),
258+
);
259+
}
260+
}
261+
235262
/**
236263
* Output some data and break the application
237264
*

0 commit comments

Comments
 (0)