Changeset 7503

Show
Ignore:
Timestamp:
03/01/07 12:00:05 (18 months ago)
Author:
peller
Message:

References #2350. Change substituteParams to substitute

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/string/extras.js

    r7502 r7503  
    1111// description: 
    1212//      For example, 
    13 //              dojo.string.substituteParams("File '${0}' is not found in directory '${1}'.",["foo.html","/temp"]); 
    14 //              dojo.string.substituteParams("File '${name}' is not found in directory '${info.dir}'.",{name: "foo.html", info: {dir: "/temp"}}); 
     13//              dojo.string.substitute("File '${0}' is not found in directory '${1}'.",["foo.html","/temp"]); 
     14//              dojo.string.substitute("File '${name}' is not found in directory '${info.dir}'.",{name: "foo.html", info: {dir: "/temp"}}); 
    1515//      both return 
    1616//              "File 'foo.html' is not found in directory '/temp'." 
  • trunk/src/widget/ComboBox.js

    r7219 r7503  
    6060                        } 
    6161                        var tss = encodeURIComponent(searchStr); 
    62                         var realUrl = dojo.string.substituteParams(this.searchUrl, {"searchString": tss}); 
     62dojo.debug("STARTSEARCH: url="+this.searchUrl+" searchString="+tss); 
     63                        var realUrl = dojo.string.substitute(this.searchUrl, {"searchString": tss}); 
     64dojo.debug("realUrl="+typeof realUrl); 
    6365                        var _this = this; 
    64                         var request = this._lastRequest = dojo.io.bind({ 
     66                        var request = (this._lastRequest = dojo.io.bind({ 
    6567                                url: realUrl, 
    6668                                method: "get", 
     
    8082                                        } 
    8183                                } 
    82                         }); 
     84                        })); 
    8385                        this._inFlight = true; 
    8486                } 
  • trunk/src/widget/Repeater.js

    r7111 r7503  
    7777                                                var name = list[j].name; 
    7878                                                var index=dojo.string.escape("regexp", this.pattern); 
    79                                                 index = index.replace(/(%\\\{index\\\})/g,"%{index}"); 
    80                                                 var nameRegexp = dojo.string.substituteParams(index, {"index": "[0-9]*"}); 
    81                                                 var newName= dojo.string.substituteParams(this.pattern, {"index": "" + i}); 
     79                                                index = index.replace(/($\\\{index\\\})/g,"${index}"); 
     80                                                var nameRegexp = dojo.string.substitute(index, {"index": "[0-9]*"}); 
     81                                                var newName= dojo.string.substitute(this.pattern, {"index": "" + i}); 
    8282                                                var re=new RegExp(nameRegexp,"g"); 
    8383                                                list[j].name = name.replace(re,newName); 
     
    8989                onDeleteRow: function(e) { 
    9090                        var index=dojo.string.escape("regexp", this.pattern); 
    91                         index = index.replace(/%\\\{index\\\}/g,"\%{index}"); 
    92                         var nameRegexp = dojo.string.substituteParams(index, {"index": "([0-9]*)"}); 
     91                        index = index.replace(/$\\\{index\\\}/g,"\${index}"); 
     92                        var nameRegexp = dojo.string.substitute(index, {"index": "([0-9]*)"}); 
    9393                        var re=new RegExp(nameRegexp,"g"); 
    9494                        this.deleteRow(re.exec(e.target.name)[1]); 
     
    133133                }, 
    134134                setRow: function(/*string*/template, /*object*/myObject) { 
    135                         //template = dojo.string.substituteParams(template, {"index": "0"}); 
     135                        //template = dojo.string.substitute(template, {"index": "0"}); 
    136136                        template= template.replace(/\%\{(index)\}/g, "0"); 
    137137                        this.rowTemplate=template; 
     
    160160                                        } else if (child.getAttribute("rowAction") != null) { 
    161161                                                if(child.getAttribute("rowAction") == "delete") { 
    162                                                         child.name=dojo.string.substituteParams(this.pattern, {"index": "" + node.row})+".delete"; 
     162                                                        child.name=dojo.string.substitute(this.pattern, {"index": "" + node.row})+".delete"; 
    163163                                                        dojo.event.connect(child, "onclick", this, "onDeleteRow"); 
    164164                                                } // if 
  • trunk/tests/string/test_extras.js

    r4127 r7503  
    11dojo.require("dojo.string.extras"); 
    22 
    3 function test_string_substituteParams(){ 
    4         var tpla = "This %{string} has %{parameters} %{toReplace}"; 
    5         var ps0 = dojo.string.substituteParams(tpla, { string: "area", parameters: "foo", toReplace: "bar"}); 
     3function test_string_substitute(){ 
     4        var tpla = "This ${string} has ${parameters} ${toReplace}"; 
     5        var ps0 = dojo.string.substitute(tpla, { string: "area", parameters: "foo", toReplace: "bar"}); 
    66        jum.assertEquals("test20", "This area has foo bar", ps0); 
    77 
     
    99        try { 
    1010                // Missing a required parameter 
    11                 var ps1 = dojo.string.substituteParams(tpla, { string: "area", parameters: "foo", extra: "baz"}); 
     11                var ps1 = dojo.string.substitute(tpla, { string: "area", parameters: "foo", extra: "baz"}); 
    1212        }catch(e){ 
    1313                thrown = e; // exception must be thrown 
     
    1515        jum.assertTrue("test21", thrown); 
    1616 
    17         var tplb = "Passed as arguments: %{0}, %{1}, %{2}."; 
    18         var ps2 = dojo.string.substituteParams(tplb, "zero", "one", "two"); 
     17        var tplb = "Passed as arguments: ${0}, ${1}, ${2}."; 
     18        var ps2 = dojo.string.substitute(tplb, ["zero", "one", "two"]); 
    1919        jum.assertEquals("test22", "Passed as arguments: zero, one, two.", ps2); 
    2020 
    2121        // Unused argument provided 
    22         var tplb = "Passed as arguments: %{0}, %{1}, %{2}."; 
    23         var ps3 = dojo.string.substituteParams(tplb, "zero", "one", "two", "three"); 
     22        var ps3 = dojo.string.substitute(tplb, ["zero", "one", "two", "three"]); 
    2423        jum.assertEquals("test23", "Passed as arguments: zero, one, two.", ps2); 
    2524 
     
    2726        try{ 
    2827                // Missing a required parameter 
    29                 var ps4 = dojo.string.substituteParams(tplb, "zero", "one"); 
     28                var ps4 = dojo.string.substitute(tplb, ["zero", "one"]); 
    3029        }catch(e){ 
    3130                thrown = e; // exception must be thrown