# Abschnitte des Layouts aus einer View füllen

> Deklariere einen Abschnitt in einer View mit @{section} und gib ihn im Layout mit @{section('name')} aus, und wähle pro Anfrage ein anderes Layout.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: de
Content-SHA256: 6d1ba98b4517041a6ada83143c932fec07b7a7d9593dd110efe9bd61f8132ffd
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Eine View kann Markup an eine benannte Stelle des Layouts schicken. Schreibe in der View `@{section name}...@{end}`; im Layout gibst du ihn mit `@{section('name')}` aus. So fügt eine Seite eigene Skripte oder einen Footer hinzu, ohne dass das Layout davon weiß.

Um für eine Anfrage ein anderes Layout zu nutzen, rufe `$.layout('name')` vor `$.view()` auf (es rendert `views/name.html` als 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');
}
```
