Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c955890 commit e304fc1Copy full SHA for e304fc1
1 file changed
Views.md
@@ -0,0 +1,32 @@
1
+## Views
2
+
3
+Unic framework support multiple view engine like php, twig etc.
4
5
+Let's set the view directory path:
6
+```php
7
+$app->set('views', base_path('views'));
8
+```
9
10
+Let's set the view engine:
11
12
+$app->set('view_engine', 'twig');
13
14
15
+Let's render a view:
16
17
+$app->get('/', function($req, $res) {
18
+ $res->render('index.twig');
19
+});
20
21
22
+Pass data to the views:
23
24
25
+ $res->locals->a = 10;
26
+ $res->render('index.twig', [
27
+ 'title' => 'Unic',
28
+ ]);
29
30
31
32
+The `$res->locals` variables are by default accessible from views.
0 commit comments