{parms}

Declares the parameters of a custom tag, with defaults, at the top of its template.

Layouts and components Single tags

Syntax

{parms name}
{parms title, subtitle='', tone='info'}

Parameters

names
The parameters, separated by commas: a name alone is required, name=default is optional with that default.

Description

{parms} stands at the top of a custom tag's template - a .pad file in _tags/ or _common - and declares which parameters the tag takes. It prints nothing.

  • A name alone is required: a caller that leaves it out gets an error - the {card} needs the parameter title=.
  • name=default is optional: what the caller left out is filled in with the default, and reads as {#name} exactly like a given parameter.

Once a tag declares its parameters, the strict check also reports a parameter that the caller gives but the tag does not declare - the tag {card} has no parameter 'titel' - it declares title, tone - so a typo at the call is caught instead of silently ignored. The items are read raw, as {attrs} reads them, so a default may be any expression.

A {parms} outside any custom tag's template is an error under the strict check. The examples use the application's tag _tags/parmsBadge.pad, which starts with {parms label, tone='info', count=0}.

Examples

Declared parameters

The badge tag declares label (required), tone and count (with defaults); the callers leave out what they like.

Templateexamples/parms/1-declare.pad
<p>
  {parmsBadge label='New'}
  {parmsBadge label='Inbox', count=3}
  {parmsBadge label='Errors', tone='danger', count=12}
</p>
Resultopen alone

New Inbox (3) Errors (12)

A parameter the tag does not declare

Under the strict check a misspelled parameter is an error - here cuont, which the badge does not declare.

Templateexamples/parms/2-typo.src
{parmsBadge label='Inbox', cuont=3}

See also

  • {slot} A named place in a custom tag's template - and the fill a caller gives it.
  • {define} Writes a custom tag in the template itself - what a _tags/name.pad file is, without the file.
  • {macro} A template function: declared parameters, given in order or by name, read as fields inside its body.
  • {shadow} The shadow root of a custom element, rendered on the server as declarative shadow DOM.
  • {attrs} Writes HTML attributes from values - quoted and escaped, a true boolean attribute bare, a false one left out.