Functiondojo.string.substitute

dojo.require("dojo.string");
defined in dojo/string.js

For example,

dojo.string.substitute("File '${0}' is not found in directory '${1}'.",["foo.html","/temp"]);
dojo.string.substitute("File '${name}' is not found in directory '${info.dir}'.",
    {name: "foo.html", info: {dir: "/temp"}});

both return

"File 'foo.html' is not found in directory '/temp'."

Usage

function (/*String*/ template, /*Object|Array*/ map, /*Function?*/ transform, /*Object?*/ thisObject) (view source)
parametertypedescription
templateStringa string with expressions in the form `${key}` to be replaced or `${key:format}` which specifies a format function.
mapObject|Arrayhash to search for substitutions
transformFunctionOptional. a function to process all parameters before substitution takes place, e.g. dojo.string.encodeXML
thisObjectObjectOptional. where to look for optional format function; default to the global namespace