Template Rendering
fastro init
command will generate folders and files like this.webapp ├── Dockerfile ├── middleware │ └── support.ts ├── public │ ├── favicon.ico │ ├── index.html │ └── logo.svg └── services ├── hello.controller.ts └── hello.template.html 3 directories, 7 files
You can render html template and pass dynamic value on it.
Open
hello.template.html
inservices
folder<html> <head> <title>${greeting} ${name}</title> </head> <body> ${greeting} ${name} </body> </html>
You can change
hello
name with other.Open
hello.controller.ts
handler.Uncomment
request.view
and commentrequest.send
.import type { Request } from "https://raw.fastro.dev/master/mod.ts"; export const handler = (request: Request) => { request.view("hello.template.html", { greeting: "Hello", name: "World" }); // request.send("hello"); };
Open url
http://localhost:3000/hello
Now you see the greeting and name on the browser.