diff -r 322d0feea350 -r 89ef5ed3c48b src/cm/media/js/lib/yui/yui_3.10.3/api/classes/YUI~substitute.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.10.3/api/classes/YUI~substitute.html Tue Jul 16 14:29:46 2013 +0200 @@ -0,0 +1,1864 @@ + + + + + YUI~substitute - YUI 3 + + + + + + + + +
+
+
+ +

+ +
+
+ API Docs for: 3.10.3 +
+
+
+ +
+ +
+
+
+ Show: + + + + + + + +
+ + +
+
+
+

YUI~substitute Class

+
+ + + + + + + + + + + Module: substitute + + + + +
+ + +
+

+ + This class is deprecated. + +

+
+ + +
+

The following methods are added to the YUI instance

+ +

Use Y.Lang.sub or Y.Template instead.

+
+ + + +
+ + +
+
+

Item Index

+ + +
+

Methods

+ + +
+ + + + + + + +
+ + +
+

Methods

+ + +
+

substitute

+ + +
+ (
    + +
  • + + s + +
  • + +
  • + + o + +
  • + +
  • + + f + +
  • + +
  • + + recurse + +
  • + +
) +
+ + + + + String + + + + + deprecated + + + + + + + + + + + + +
+ + + +

+ + Defined in + + + + + substitute/js/substitute.js:20 + +

+ + + + + +
+ +
+

Use Y.Lang.sub or Y.Template instead.

+ +

Does {placeholder} substitution on a string. The object passed as the +second parameter provides values to replace the {placeholder}s. +{placeholder} token names must match property names of the object. For +example

+ +

var greeting = Y.substitute("Hello, {who}!", { who: "World" });

+ +

{placeholder} tokens that are undefined on the object map will be left in +tact (leaving unsightly "{placeholder}"s in the output string). If your +replacement strings should include curly braces, use {LBRACE} and +{RBRACE} in your object map string value.

+ +

If a function is passed as a third argument, it will be called for each +{placeholder} found. The {placeholder} name is passed as the first value +and the value from the object map is passed as the second. If the +{placeholder} contains a space, the first token will be used to identify +the object map property and the remainder will be passed as a third +argument to the function. See below for an example.

+ +

If the value in the object map for a given {placeholder} is an object and +the dump module is loaded, the replacement value will be the string +result of calling Y.dump(...) with the object as input. Include a +numeric second token in the {placeholder} to configure the depth of the call +to Y.dump(...), e.g. "{someObject 2}". See the +dump method for details.

+
+ + +
+

Parameters:

+ +
    + +
  • + + s + String + + + + +
    +

    The string that will be modified.

    +
    + + +
  • + +
  • + + o + Object + + + + +
    +

    An object containing the replacement values.

    +
    + + +
  • + +
  • + + f + Function + + + + +
    +

    An optional function that can be used to + process each match. It receives the key, + value, and any extra metadata included with + the key inside of the braces.

    +
    + + +
  • + +
  • + + recurse + Boolean + + + + +
    +

    if true, the replacement will be recursive, + letting you have replacement tokens in replacement text. + The default is false.

    +
    + + +
  • + +
+
+ + + +
+

Returns:

+ +
+ + + String: + + the substituted string. + +
+
+ + + +
+

Example:

+ +
+
    function getAttrVal(key, value, name) {
+        // Return a string describing the named attribute and its value if
+        // the first token is @. Otherwise, return the value from the
+        // replacement object.
+        if (key === "@") {
+            value += name + " Value: " + myObject.get(name);
+        }
+        return value;
+    }
+
+    // Assuming myObject.set('foo', 'flowers'),
+    // => "Attr: foo Value: flowers"
+    var attrVal = Y.substitute("{@ foo}", { "@": "Attr: " }, getAttrVal);
+
+
+
+ +
+ + +
+ + + + + + + +
+
+ +
+
+
+
+
+
+ + + + + + + + + +