attr static method
Escape values for placement inside a HTML or XML attribute.
Returns a string where all characters &, <, >, ' and " in the string
representation of value
is replaced by its HTML entities.
The string representation is produced by invoking toString
on the value.
If value
is null, the empty string is returned.
Implementation
static String attr(Object? value) {
if (value != null) {
var s = value.toString().replaceAll('&', '&');
s = s.replaceAll('<', '<');
s = s.replaceAll('>', '>');
s = s.replaceAll("'", ''');
s = s.replaceAll('"', '"');
return s;
} else {
return '';
}
}