# Riempire sezioni del layout da una vista

> Dichiara una sezione in una vista con @{section} e stampala nel layout con @{section('name')}, e scegli un altro layout per richiesta.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: it
Content-SHA256: 934fc9e28533e4e4ce5cd6490e6476e07bc253ba7e53ce6e54baecac3fe211dc
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Una vista può inviare markup a un punto con nome del layout. Nella vista scrivi `@{section name}...@{end}`; nel layout stampala con `@{section('name')}`. È così che una pagina aggiunge i propri script o il proprio footer senza che il layout lo sappia.

Per usare un layout diverso per una richiesta chiama `$.layout('name')` prima di `$.view()` (renderizza `views/name.html` come layout).

```html views/layout.html
<html><body>@{body}<footer>@{section('footer')}</footer></body></html>
```

```html views/layout-wide.html
<html><body class="wide">@{body}</body></html>
```

```html views/index.html
@{section footer}
	<span>Footer from the view</span>
@{end}
<h1>Home</h1>
```

```js controllers/default.js
exports.install = function() {
	ROUTE('GET /', home);
	ROUTE('GET /wide/', wide);
};

function home($) {
	$.view('index');
}

function wide($) {
	$.layout('layout-wide');
	$.view('index');
}
```
