New applications prefer Inertia for screens a person uses. Views are still how you return HTML, including mail and a page you want to work without the React bundle. Field Notes uses one: a share page for a single note.
Create resources/views/notes/share.html. The view name is the path inside resources/views, without .html, with dots for directories. view("notes.share", ...) is this file. view("notes/share.html", note) is not the documented call.
<!doctype html>
<html lang="en">
<body>
<h1>{{ note.title }}</h1>
<p>{{ note.body }}</p>
<p>{{ note.user.name }}</p>
</body>
</html>
use laravel::prelude::*;
use laravel::view::View;
use crate::models::Note;
pub async fn share(mut note: Note) -> laravel::Result<View> {
note.load(Note::user).await?;
Ok(view("notes.share", data! { note }))
}
data! passes the local under its own name. name => value renames it. The views guide’s nested example is view("admin.profile", data! { name => "Taylor" }). Route the handler at GET /notes/{note}/share in web.rs if you want the session, or with routes() if this page should not require cookies. Field Notes keeps it on web so the same binding and load you already know still apply. It does not sit behind Authenticate. A share link is for someone who is not the author.
Jinja escapes every value. A body that contains <script> is rendered as text. That is the behavior this checkpoint checks. Html::raw and with_html opt out of escaping for markup you produced yourself, such as Markdown that the markdown crate already escaped. The views guide’s warning is the rule: do not pass untrusted note text to Html::raw.
laravel dev reloads the browser when a file under resources/views/ changes. You do not rebuild Rust to fix a typo in the template.
Mail views live in the same tree, under resources/views/mail/. The next course names a mailable NoteShared and expects resources/views/mail/note-shared.html. The share page you just wrote is the same template system, aimed at a browser instead of an inbox.
Check your work
Put a <script> tag in a note body and open the share URL. The page should show the tag as text.