Fill sections of the layout from a view
A view can send markup to a named place of the layout. In the view write @{section name}...@{end}; in the layout print it with @{section('name')}. This is how a page adds its own scripts or footer without the layout knowing about it.
To use a different layout for a request call $.layout('name') before $.view() (it renders views/name.html as the layout).
<html><body>@{body}<footer>@{section('footer')}</footer></body></html><html><body class="wide">@{body}</body></html>@{section footer}
<span>Footer from the view</span>
@{end}
<h1>Home</h1>exports.install = function() {
ROUTE('GET /', home);
ROUTE('GET /wide/', wide);
};
function home($) {
$.view('index');
}
function wide($) {
$.layout('layout-wide');
$.view('index');
}