spUtil - format(String template, Object data)

Formats a string as an alternative to string concatenation.

Use this method to build a string with variables.

Table 1. Parameters
Name Type Description
template String

String template with values for substitution.

data Object Object containing variables for substitution.
Table 2. Returns
Type Description
String A formatted string.
spUtil.format('An error ocurred: {error} when loading {widget}', {error: '404', widget: 'sp-widget'})


'An error occurred: 404 when loading sp-widget'