{tab}
One item of a tabs, accordion or carousel: its label and its content, handed to that owner.
Syntax
{tab 'label'} ... {/tab}
Parameters
-
label -
The tab's label, the summary of an accordion item or the caption of a carousel slide. Required in
{tabs}and{accordion}, optional in{carousel}.
Description
{tab} is the item of the three widgets that take a list of labelled parts: {tabs} (a tab and its panel), {accordion} (a <details> with the label as its summary) and {carousel} (a slide with the label as its caption). It prints nothing where it stands: its content is rendered, trimmed, and handed to the nearest of those owners above it, which builds its markup from the items once its own content has rendered.
Because the hand-over goes to the nearest owner and not to the direct parent, a tab may stand inside an {if}, or inside a loop that makes a tab per row of data: {tabs}{plans}{tab $name}...{/tab}{/plans}{/tabs}.
Under the strict check a {tab} outside any owner is an error, as is one that never closes, and a tab of a {tabs} or an {accordion} without a label. A carousel slide may go without a label; it then has no caption.
Examples
A tab in an if
A tab only shows up when its condition holds - the hand-over skips the if around it.
{set $hasReviews = 0}
{tabs}
{tab 'Overview'}<p>A kettle in brushed steel.</p>{/tab}
{if $hasReviews gt 0}
{tab 'Reviews'}<p>The reviews.</p>{/tab}
{/if}
{tab 'Delivery'}<p>Delivered the next working day.</p>{/tab}
{/tabs}
A kettle in brushed steel.
Delivered the next working day.
The same tabs, another owner
Identical tab items laid out by an accordion instead of a tab set.
{accordion}
{tab 'Overview'}<p>A kettle in brushed steel.</p>{/tab}
{tab 'Delivery'}<p>Delivered the next working day.</p>{/tab}
{/accordion}
Overview
A kettle in brushed steel.
Delivery
Delivered the next working day.
See also
- {tabs} Panels behind a row of tabs, switched by radio buttons and CSS - no JavaScript.
- {accordion} Items that open and close on a click, each a details element - no JavaScript.
- {carousel} Slides in a row that scrolls and snaps sideways, with arrow links and dots - no JavaScript needed.