SimileAjax/String

From SIMILE Widgets
Jump to: navigation, search

Contents

SimileAjax String

There is no SimileAjax.String namespace. Extends the native string type with utility functions.

Code: http://api.simile-widgets.org/ajax/2.2.1/scripts/string.js

Migration Notes

jQuery may provide some of these? It almost certainly does as methods, not as as type extensions. These may come with. The substitute method described below is probably a necessity depending on where it's used.

Back to SimileAjax.

Methods

All of these operate on strings.

String.prototype.trim

Returns: string
Description: Remove leading and ending spaces.

String.prototype.startsWith

Arguments:
prefix: string
Returns: boolean
Description: Check if string begins with prefix substring

String.prototype.endsWith

Arguments:
suffix: string
Returns: boolean
Description: Check if string ends with suffix substring

String.substitute

Arguments:
s: string, String to run replacements on
objects: array
Returns: string
Description: Take a templated string and substitute all instances of %n where n is the index of an object in objects.

Back to SimileAjax.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox