enyo.string

enyo.string collects a number of utility methods for working with strings.

Methods

enyo.string.applyFilterHighlight(inText, inSearchText, inClassName)

Performs a case-insensitive search for inSearchText within inText; any matches are wrapped in a <span> tag with a CSS class of inClassName, and the (potentially) modified inText string is returned.

enyo.string.escapeHtml(inText)

Returns the passed-in string with <, >, and & replaced by the corresponding HTML entities (&lt;, &gt;, and &amp;).

For example, enyo.string.escapeHtml("This & That") returns This &amp; That.

enyo.string.escapeHtmlAttribute(inText)

Returns the passed-in string with & and " replaced by the corresponding HTML entities (&amp; and &quot;).

enyo.string.trim(inString)

Returns the passed-in string with whitespace at the beginning and end removed.

enyo.string.stripQuotes(inString)

Returns the passed-in string with leading and trailing quote characters removed.

For example, enyo.string.stripQuotes("foo") returns foo.

enyo.string.removeHtml(inHtml)

Returns a text-only version of a string that may contain HTML.

enyo.string.runTextIndexer(inText, inOptions)

Searches inText for URLs (web and mailto) and emoticons (if supported), and returns a new string with those entities replaced by HTML links and images (respectively).

inOptions is an object with fields having the following names and default values:

{
  phoneNumber: true,
  emailAddress: true,
  webLink: true,
  schemalessWebLink: true,
  emoticon: true
}

Passing false as the value for a field will prevent LunaSysMgr from HTML-izing that text type.

enyo.string.toBase64(inText)

Encodes the string inText to Base64 and returns the encoded string.

enyo.string.fromBase64(inText)

Decodes the string inText from Base64 and returns the decoded string. Throws an exception on bad input.