Generates the value for the href
HTML attribute of an
anchor (a
) tag.
When the resulting link is clicked or tapped, it opens the email software and suggests composing a new email
to the specified address passed as a single parameter.
- const targetEmailAddress = "sample@example.com";
a(
href=buildEmailLinkHrefAttributeValue(targetEmailAddress)
)= targetEmailAddress
This function appends "mailto:"
to the provided
string value, which is expected to be a valid email address.
If your code editor or Integrated Development Environment (IDE) lacks template
autocompletion functionality, this function may not be as convenient.
Without autocompletion, you would need to memorize either "mailto:"
or the
function name buildEmailLinkHrefAttributeValue
.
If you forget, which is common, you will need to refer to the documentation each time.
If your code editor or IDE supports template autocompletion, entering
"buildE..."
is usually sufficient to trigger a popup hint.
The subsequent actions depend on how autocomplete is implemented.
For instance, with the
Live Templates from the
official YDF plugin for the
IntelliJ IDEA family IDEs the value, previously copied to the clipboard, is automatically inserted into the position of the
single parameter.
Thus, completing the input of the href
attribute using the
buildEmailLinkHrefAttributeValue
function typically requires
only 3-4 keystrokes (depending on the number of other suggested autocompletions):