Warning: Use of undefined constant Symbol - assumed 'Symbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215 Warning: Use of undefined constant JavaScriptSymbol - assumed 'JavaScriptSymbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215

dojo/string.js

  • Provides:

    • dojo.string
  • dojo.string

    • summary
      String utilities for Dojo
    • type
      Object
  • dojo.string.rep

    • parameters:
      • str: (typeof String)
        the string to replicate
      • num: (typeof Integer)
        number of times to replicate the string
    • returns
      String
    • summary
      Efficiently replicate a string <code>n</code> times.
    • type
      Function
  • dojo.string.pad

    • parameters:
      • text: (typeof String)
        the string to pad
      • size: (typeof Integer)
        length to provide padding
      • ch: (typeof String)
        character to pad, defaults to '0'
      • end: (typeof Boolean)
        adds padding at the end if true, otherwise pads at start
    • returns
      String
    • summary
      Pad a string to guarantee that it is at least <code>size</code> length by
      filling with the character <code>ch</code> at either the start or end of the
      string. Pads at the start, by default.
    • example
      	// Fill the string to length 10 with "+" characters on the right.  Yields "Dojo++++++".
      	dojo.string.pad("Dojo", 10, "+", true);
    • type
      Function
  • dojo.string.substitute

    • parameters:
      • template: (typeof String)
        a string with expressions in the form <code>${key}</code> to be replaced or
        <code>${key:format}</code> which specifies a format function. keys are case-sensitive.
      • map: (typeof Object|Array)
        hash to search for substitutions
      • transform: (typeof Function)
        a function to process all parameters before substitution takes
        place, e.g. mylib.encodeXML
      • thisObject: (typeof Object)
        where to look for optional format function; default to the global
        namespace
    • summary
      Performs parameterized substitutions on a string. Throws an
      exception if any parameter is unmatched.
    • example
      Substitutes two expressions in a string from an Array or Object
      	// returns "File 'foo.html' is not found in directory '/temp'."
      	// by providing substitution data in an Array
      	dojo.string.substitute(
      		"File '${0}' is not found in directory '${1}'.",
      		["foo.html","/temp"]
      	);
      
      	// also returns "File 'foo.html' is not found in directory '/temp'."
      	// but provides substitution data in an Object structure.  Dotted
      	// notation may be used to traverse the structure.
      	dojo.string.substitute(
      		"File '${name}' is not found in directory '${info.dir}'.",
      		{ name: "foo.html", info: { dir: "/temp" } }
      	);
    • example
      Use a transform function to modify the values:
      	// returns "file 'foo.html' is not found in directory '/temp'."
      	dojo.string.substitute(
      		"${0} is not found in ${1}.",
      		["foo.html","/temp"],
      		function(str){
      			// try to figure out the type
      			var prefix = (str.charAt(0) == "/") ? "directory": "file";
      			return prefix + " '" + str + "'";
      		}
      	);
    • example
      Use a formatter
      	// returns "thinger -- howdy"
      	dojo.string.substitute(
      		"${0:postfix}", ["thinger"], null, {
      			postfix: function(value, key){
      				return value + " -- howdy";
      			}
      		}
      	);
    • type
      Function
  • dojo.global

    • type
      Object
  • dojo.string.trim

    • parameters:
      • str: (typeof String)
        String to be trimmed
    • returns
      String
    • summary
      Trims whitespace from both sides of the string
    • return_summary
      String
      Returns the trimmed string
    • description
      This version of trim() was taken from [Steven Levithan's blog](http://blog.stevenlevithan.com/archives/faster-trim-javascript).
      The short yet performant version of this function is dojo.trim(),
      which is part of Dojo base.  Uses String.prototype.trim instead, if available.
    • type
      Function
  • dojo

    • type
      Object