Layouts: extends, block and parent

The directories give a page its frame - every _inits.pad and _exits.pad on the way to it. A layout is a frame the page picks itself, wherever it lives, and whose regions it can override one by one. This is _layouts/report.pad:

<div style="border: 1px solid #999; padding: 6px">
<h3>{block 'title'}Report{/block}</h3>
<div>{block 'sidebar'}<a href="?index">Home</a>{/block}</div>
@page@
<small>{block 'footer'}Generated by PAD{/block}</small>
</div>

A page that extends it fills in the title, adds to the sidebar and leaves the footer as it is:

PHP
HTML
fragments/layouts_1.pad
Result
{extends '_layouts/report'}

{block 'title'}Sales report{/block}

{block 'sidebar'}
{parent} | <a href="?pages/data_answers">Export</a>
{/block}

<p>Revenue this month: 12.500</p>

Sales report

Revenue this month: 12.500

Generated by PAD

The three tags

What the page holds outside its blocks goes where the layout writes @page@, or in front of the layout when it has none.

Blocks in the directory wrappers

The blocks of an ordinary _inits.pad are regions too, so a page that extends nothing still overrides them: with <title>{block 'title'}My site{/block}</title> in the wrapper, a page sets its own title with {block 'title'}Sales{/block} - no PHP needed. A block of such a page that overrides nothing renders where it stands.

Resolved before rendering

Blocks are put together in the text while the page is assembled, before anything renders, so they cost nothing at run time. Under the strict check a block of an extending page that overrides nothing is reported - usually a misspelt name - and so is an {extends} inside another tag, where the assembly does not look.