HTML escape modes.

Allows specifying a mode for HTML escaping that depend on the context where the escaped result is going to be used. The relevant contexts are:

  • as text content of an HTML element.
  • as value of a (single- or double-) quoted attribute value.

All modes require escaping of & (ampersand) characters, and may enable escaping of more characters.

Custom escape modes can be created using the HtmlEscapeMode.HtmlEscapeMode constructor.

Constants

ATTRIBUTE HtmlEscapeMode

Escaping mode for text going into double-quoted HTML attribute values.

const HtmlEscapeMode._('attribute', true, true, false, false)
ELEMENT HtmlEscapeMode

Escaping mode for text going into HTML element content.

const HtmlEscapeMode._('element', true, false, false, false)
SQ_ATTRIBUTE HtmlEscapeMode

Escaping mode for text going into single-quoted HTML attribute values.

const HtmlEscapeMode._('attribute', true, false, true, false)
UNKNOWN HtmlEscapeMode

Default escaping mode which escape all characters.

const HtmlEscapeMode._('unknown', true, true, true, true)

Constructors

HtmlEscapeMode({String name: "custom", bool escapeLtGt: false, bool escapeQuot: false, bool escapeApos: false, bool escapeSlash: false })

Create a custom escaping mode.

const

Properties

escapeApos bool

Whether to escape "'" (apostrophe).

read-only
escapeLtGt bool

Whether to escape '<' and '>'.

read-only
escapeQuot bool

Whether to escape '"' (quote).

read-only
escapeSlash bool

Whether to escape "/" (forward slash, solidus).

read-only
hashCode int

Get a hash code for this object.

read-only, inherited
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) bool

The equality operator.

inherited

Methods

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
toString() String

Returns a string representation of this object.