Skip to content

Commit ea5958e

Browse files
committed
Update
1 parent 3a1296e commit ea5958e

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

app/Front/Docs/Content/framework/04-views.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,7 @@ Tempest supports three templating engines: Tempest View, Twig, and Blade. Tempes
66

77
## View files
88

9-
Tempest Views are plain PHP files, although they also support a custom syntax. You can mix or choose a preferred style.
10-
11-
This is the standard PHP style:
12-
13-
```html
14-
<ul>
15-
<?php foreach ($this->posts as $post): ?>
16-
<li>
17-
<?= $post->title ?>
18-
19-
<?php if($this->showDate($post)): ?>
20-
<span>
21-
<?= $post->date ?>
22-
</span>
23-
<?php endif; ?>
24-
</li>
25-
<?php endforeach; ?>
26-
</ul>
27-
```
28-
29-
And this is the custom syntax:
9+
Here's an example of what a Tempest view looks like:
3010

3111
```html
3212
<x-base title="Home">
@@ -48,7 +28,7 @@ And this is the custom syntax:
4828
</x-base>
4929
```
5030

51-
Think of the custom style as an extension of HTML, we'll dive deeper into the syntax later in this chapter.
31+
You can think of `tempest/view` as a superset of HTML, we'll dive deeper into the syntax later in this chapter.
5232

5333
## Returning Views
5434

@@ -84,6 +64,23 @@ final readonly class HomeController
8464

8565
The `{php}view()` function will construct a generic view object for you. It's more flexible, but custom view objects offer some benefits.
8666

67+
### View paths
68+
69+
View files can be referenced in multiple ways. You can use absolute paths:
70+
71+
```php
72+
view(__DIR__ . '/../Views/home.view.php');
73+
```
74+
75+
Or you can use relative paths:
76+
77+
78+
```php
79+
view('Views/home.view.php');
80+
```
81+
82+
When you're using relative paths, Tempest will search all registered [discovery locations](/docs/internals/discovery), as well as files relative to the controller where the view was created. For example, if you write `view('./home.view.php)`, Tempest will first check whether there's a view file within the same directory as where the controller requiring this view is located.
83+
8784
## Escaping data
8885

8986
Tempest supports both a custom echo tag, and raw PHP tags to write data to views:

0 commit comments

Comments
 (0)