ol-ishare/string

Methods

(inner) template(str, data, strict) → {String}

Simple templating facility, accepts a template string of the form 'Hello ${a}, ${b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string 'Hello foo, bar'. You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument.

Parameters:
Name Type Default Description
str String

String with template placeholders

data Object

Object with properties corrisponding with placeholders

strict Boolean false

When true throw an Error when str contains a placeholder for which there is no corresponding property in data. Defaults to false.

Returns:

str with placeholders replaced with values from data

Type
String