Blockly.utils. parsing
Methods
checkMessageReferences
checkMessageReferences(message) returns boolean
Validates that any %{MSG_KEY} references in the message refer to keys of the Msg string table.
Parameter |
|
---|---|
message |
string Text which might contain string table references. |
- Returns
-
boolean
True if all message references have matching values. Otherwise, false.
parseBlockColour
parseBlockColour(colour) returns Object
Parse a block colour from a number or string, as provided in a block definition.
Parameter |
|
---|---|
colour |
(number or string) HSV hue value (0 to 360), #RRGGBB string, or a message reference string pointing to one of those two values. |
- Throws
-
Error
If the colour cannot be parsed. - Returns
-
{hue: nullable number, hex: string}
An object containing the colour as a #RRGGBB string, and the hue if the input was an HSV hue value.
replaceMessageReferences
replaceMessageReferences(message) returns string
Replaces string table references in a message, if the message is a string. For example, "%{bky_my_msg}" and "%{BKY_MY_MSG}" will both be replaced with the value in Msg['MY_MSG'].
Parameter |
|
---|---|
message |
(string or unknown) Message, which may be a string that contains string table references. |
- Returns
-
string
String with message references replaced.
tokenizeInterpolation
tokenizeInterpolation(message) returns Array of (string or number)
Parse a string with any number of interpolation tokens (%1, %2, ...). It will also replace string table references (e.g., %{bky_my_msg} and %{BKY_MY_MSG} will both be replaced with the value in Msg['MY_MSG']). Percentage sign characters '%' may be self-escaped (e.g., '%%').
Parameter |
|
---|---|
message |
string Text which might contain string table references and interpolation tokens. |
- Returns
-
non-null Array of (string or number)
Array of strings and numbers.