new Content(messages)
Create an instance of Content
Parameters:
Name | Type | Description |
---|---|---|
messages |
Array.<Object.<string, string>> | The messages with optional tokens mapped by message id |
- Source:
Extends
Methods
-
<static> loadCsv(options)
-
Loads messages from a CSV file
Parameters:
Name Type Description options
module:nyc/Content~Content.LoadOptions The load options
- Source:
Returns:
The promise that will resolve to an instance of module:nyc/Content~Content
- Type
- Promise
-
message(msgId [, values])
-
Returns a content message with substituted values
Parameters:
Name Type Argument Description msgId
string The id for the message
values
Object.<string, string> <optional>
The substitution values
- Source:
Returns:
The message with substituted values if provided
- Type
- string
-
replace(str, values)
-
Replace tokens in a string with values from a provided object
Parameters:
Name Type Description str
string String with tokens to be replaced
values
Object.<string, string> Values token for replacement
- Inherited From:
- Overrides:
- Source:
Returns:
String with replacement value substitution
- Type
- string
Type Definitions
-
LoadOptions
-
Options for loading CSV content using module:nyc/Content~Content.loadCsv
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description url
string The URL to a CSV source
key
string <optional>
'key' The key column for CSV messages
value
string <optional>
'value' The key column for CSV messages
messages
Array.<Object.<string, string>> <optional>
Other messages