The Content Construct
A content store is a named block of template, defined once and usable anywhere after it. The content tag page covers defining one and the ways two blocks merge; this page is about what the construct does for a whole page: one block, many tags, each deciding how to wear it.
A store used by name
Writing the store's name as a tag renders it. The tag may bring content of its own - without merge= the store comes first, and merge='bottom' or merge='replace' say otherwise:
|
PHP |
HTML fragments/content_1.pad |
Result |
|---|---|---|
|
Check your input. Check your input.Also: Then retry: Check your input. |
The @content@ placeholder
Instead of joining end to end, either side may carry @content@: whichever side has it, the other is dropped into that spot. A store shaped like a frame turns every usage into its filling:
|
PHP |
HTML fragments/content_2.pad |
Result |
|---|---|---|
|
[ one ] [ two ] |
content= on any tag, and a store with two halves
Every tag takes a content= option naming a store, with the same merge= choices. And a store may carry an @else@ of its own: which half is used is decided by the tag wearing it - the same store gives its first half to a tag that produced something and its second half to one that came up empty:
|
PHP |
HTML fragments/content_3.pad |
Result |
|---|---|---|
|
Found: first Found: second Nothing there. |