escapeAttribute static method

String escapeAttribute(
  1. String input
)

Escape for use inside an HTML attribute value

Implementation

static String escapeAttribute(String input) {
  return input
      .replaceAll('&', '&')
      .replaceAll('"', '"')
      .replaceAll("'", ''')
      .replaceAll('<', '&lt;')
      .replaceAll('>', '&gt;');
}