string.sub
string.sub(str, data, remove)
Parameters
- str
{String}:a string with {curly brace} delimited property names
- data
{Object}:an object from which to read properties
Returns
{String|null}:
the supplied string with delimited properties replaced with their values if all properties exist on the object, null otherwise
If remove is true, the properties found in delimiters in str are removed from data.
var string = require("can-util/js/string/string");
console.log(string.sub("foo_{bar}", {bar: "baz"}})); // -> "foo_baz"
console.log(string.sub("foo_{bar}", {})); // -> null