HTML attribute helpers
Two tags write the parts of an HTML tag that depend on data, so a template needs no {if} inside a tag to leave an attribute out.
|
PHP fragments/html_1.php |
HTML fragments/html_1.pad |
Result |
|---|---|---|
|
|
A panel
|
The result is easiest to see in the page source: the button reads <button disabled title="Saves the "draft" <now>" aria-expanded="false"> and the div class="panel active".
attrs
-
name=expression- the attribute with its value, quoted and escaped. - A boolean HTML attribute -
disabled,checked,selected,required,hidden... - is written bare when its value is true and left out when it is not. - Any other attribute is left out for FALSE, written bare for TRUE, and otherwise written with its value: the text
falsestaysaria-expanded="false". - The names are attribute names, dashes included -
data-id,aria-label- and never engine options:content=is the meta attribute.
classes
- An expression without a name - a string of names, or an array - is always in.
-
name=conditionputs the name in when the condition holds. - The list is deduplicated and escaped.