#attr
Details | |
---|---|
name | attr |
type | attribute |
value | executed; 2 to 3 parts expression. |
related attributes | none |
description | An attribute that allows you to conditionally set an attribute on a tag based on a condition. |
Two parts value
For two parts value the first one is the name of the attribute and the second is the condition expression.
This is to handle boolean attributes like hidden, disabled, checked, etc. Attributes that do not need a value.
<input #attr="checked, $data.accepted" type="checkbox">
<button #attr="disabled, submitted" type="submit">Submitted</button>
Three parts value
For three parts value the first one is the name of the attribute and the second is the value and the third is the condition expression.
<h2 #attr="style, {$data.title.style}, $data.title.style ">Heading</h2>
<h2 #attr="id, site-title, $data.page === '/'">Heading</h2>