ForgeTotal.js 5
it

Total.js 5

Renderizzare una vista senza scrivere un handler

Total.js 5 · total5@0.0.19 routingviews Eseguita con Total.js 5

Quando una route non ha un handler, Total.js renderizza una vista per essa: views/about.html per /about/ e views/index.html per /. Puoi anche dare tu il nome alla vista passando una stringa invece di una funzione.

views/layout.html
<!DOCTYPE html><html><body>@{body}</body></html>
views/index.html
<h1>Home</h1>
views/about.html
<h1>About us</h1>
views/contact-page.html
<h1>Contact</h1>
controllers/default.js
exports.install = function() {
	ROUTE('GET /');
	ROUTE('GET /about/');
	ROUTE('GET /contact/', 'contact-page');
};