# Wypełnianie sekcji layoutu z widoku

> Zadeklaruj sekcję w widoku przez @{section} i wypisz ją w layoutcie przez @{section('name')}, a dla żądania wybierz inny layout.

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

Widok może wysłać znaczniki do nazwanego miejsca layoutu. W widoku napisz `@{section name}...@{end}`; w layoutcie wypisz ją przez `@{section('name')}`. Tak strona dodaje własne skrypty lub stopkę, a layout o nich nie wie.

Aby użyć innego layoutu dla żądania, wywołaj `$.layout('name')` przed `$.view()` (renderuje `views/name.html` jako 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');
}
```
