string.replaceWith
string.replaceWith(str, data, replacer, remove)
Parameters
- str
{String}
:string with {curly brace} delimited property names
- data
{Object}
:object from which to read properties
- replacerfunction
{function}
:which returns string replacements
- shouldRemoveMatchedPaths
{Boolean}
:whether to remove properties found in delimiters in
str
fromdata
Returns
{String}
:
the supplied string with delimited properties replaced with their values
var string = require("can-util/js/string/string");
var answer = string.replaceWith(
'{.}{.}{.}{.}{.} Batman!',
{},
() => 'Na'
);
// => 'NaNaNaNaNa Batman!'