Show:

ia.TextSubstitution Class

Module: ia

The TextSubstitution class contains functions for variable subtitution in strings.

All variables are indicated by the name of the variable. This class registers these names with variable values, allowing the lookup of variable values by the variable name. The set of available variables can be extended by using the static setVariable method to register a new variable name and value.

Constructor

ia.TextSubstitution

()

Methods

_formatValue

(
  • variableString
  • index
)
String private

Extracts a variable / string / number from a conditional statement.

Parameters:

  • variableString String

    The conditional statement.

  • index Number

    The position of the variable in the statement.

Returns:

String: The variable or an empty string.

_leftTrim

(
  • s
)
String private

Removes whitespace from the left side of a string.

Parameters:

  • s String

    The string.

Returns:

String: String with whitespace removed.

_processVariable

(
  • variableString
)
private

Processes a conditional statement.

Parameters:

  • variableString String

    The variable string.

_replace

(
  • s
  • pattern
  • replacement
)
String private

Replaces a pattern in a string with a new pattern. eg. All occurrences of ";" may be replaced with ";".

Parameters:

  • s String

    The string.

  • pattern String

    The pattern.

  • replacement String

    The pattern replacements.

Returns:

String: The input string with the pattern replaced.

_rightTrim

(
  • s
)
String private

Removes whitespace from the right side of a string.

Parameters:

  • s String

    The string.

Returns:

String: The input string with whitespace removed.

_trim

(
  • s
)
String private

Removes whitespace from a string.

Parameters:

  • s String

    The string.

Returns:

String: The input string with whitespace removed.

clearVariables

()

Clears the variables.

formatMessage

(
  • msg
)
String

Replaces all instances of a variable name in a string with the 'real' values.

Parameters:

  • msg String

    The input string which may contain variable names, for example: 'Current theme is: ${themeName1}'.

Returns:

String: The input string with all variables substituted out.

setVariable

(
  • name
  • value
)

Sets the value for the given substitution variable.

Parameters:

  • name String

    The name of the variable

  • value String

    The value of the variable.