Changeset 7503
- Timestamp:
- 03/01/07 12:00:05 (18 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
src/string/extras.js (modified) (1 diff)
-
src/widget/ComboBox.js (modified) (2 diffs)
-
src/widget/Repeater.js (modified) (4 diffs)
-
tests/string/test_extras.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/string/extras.js
r7502 r7503 11 11 // description: 12 12 // For example, 13 // dojo.string.substitute Params("File '${0}' is not found in directory '${1}'.",["foo.html","/temp"]);14 // dojo.string.substitute Params("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"}}); 15 15 // both return 16 16 // "File 'foo.html' is not found in directory '/temp'." -
trunk/src/widget/ComboBox.js
r7219 r7503 60 60 } 61 61 var tss = encodeURIComponent(searchStr); 62 var realUrl = dojo.string.substituteParams(this.searchUrl, {"searchString": tss}); 62 dojo.debug("STARTSEARCH: url="+this.searchUrl+" searchString="+tss); 63 var realUrl = dojo.string.substitute(this.searchUrl, {"searchString": tss}); 64 dojo.debug("realUrl="+typeof realUrl); 63 65 var _this = this; 64 var request = this._lastRequest = dojo.io.bind({66 var request = (this._lastRequest = dojo.io.bind({ 65 67 url: realUrl, 66 68 method: "get", … … 80 82 } 81 83 } 82 }) ;84 })); 83 85 this._inFlight = true; 84 86 } -
trunk/src/widget/Repeater.js
r7111 r7503 77 77 var name = list[j].name; 78 78 var index=dojo.string.escape("regexp", this.pattern); 79 index = index.replace(/( %\\\{index\\\})/g,"%{index}");80 var nameRegexp = dojo.string.substitute Params(index, {"index": "[0-9]*"});81 var newName= dojo.string.substitute Params(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}); 82 82 var re=new RegExp(nameRegexp,"g"); 83 83 list[j].name = name.replace(re,newName); … … 89 89 onDeleteRow: function(e) { 90 90 var index=dojo.string.escape("regexp", this.pattern); 91 index = index.replace(/ %\\\{index\\\}/g,"\%{index}");92 var nameRegexp = dojo.string.substitute Params(index, {"index": "([0-9]*)"});91 index = index.replace(/$\\\{index\\\}/g,"\${index}"); 92 var nameRegexp = dojo.string.substitute(index, {"index": "([0-9]*)"}); 93 93 var re=new RegExp(nameRegexp,"g"); 94 94 this.deleteRow(re.exec(e.target.name)[1]); … … 133 133 }, 134 134 setRow: function(/*string*/template, /*object*/myObject) { 135 //template = dojo.string.substitute Params(template, {"index": "0"});135 //template = dojo.string.substitute(template, {"index": "0"}); 136 136 template= template.replace(/\%\{(index)\}/g, "0"); 137 137 this.rowTemplate=template; … … 160 160 } else if (child.getAttribute("rowAction") != null) { 161 161 if(child.getAttribute("rowAction") == "delete") { 162 child.name=dojo.string.substitute Params(this.pattern, {"index": "" + node.row})+".delete";162 child.name=dojo.string.substitute(this.pattern, {"index": "" + node.row})+".delete"; 163 163 dojo.event.connect(child, "onclick", this, "onDeleteRow"); 164 164 } // if -
trunk/tests/string/test_extras.js
r4127 r7503 1 1 dojo.require("dojo.string.extras"); 2 2 3 function test_string_substitute Params(){4 var tpla = "This %{string} has %{parameters} %{toReplace}";5 var ps0 = dojo.string.substitute Params(tpla, { string: "area", parameters: "foo", toReplace: "bar"});3 function test_string_substitute(){ 4 var tpla = "This ${string} has ${parameters} ${toReplace}"; 5 var ps0 = dojo.string.substitute(tpla, { string: "area", parameters: "foo", toReplace: "bar"}); 6 6 jum.assertEquals("test20", "This area has foo bar", ps0); 7 7 … … 9 9 try { 10 10 // Missing a required parameter 11 var ps1 = dojo.string.substitute Params(tpla, { string: "area", parameters: "foo", extra: "baz"});11 var ps1 = dojo.string.substitute(tpla, { string: "area", parameters: "foo", extra: "baz"}); 12 12 }catch(e){ 13 13 thrown = e; // exception must be thrown … … 15 15 jum.assertTrue("test21", thrown); 16 16 17 var tplb = "Passed as arguments: %{0}, %{1}, %{2}.";18 var ps2 = dojo.string.substitute Params(tplb, "zero", "one", "two");17 var tplb = "Passed as arguments: ${0}, ${1}, ${2}."; 18 var ps2 = dojo.string.substitute(tplb, ["zero", "one", "two"]); 19 19 jum.assertEquals("test22", "Passed as arguments: zero, one, two.", ps2); 20 20 21 21 // 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"]); 24 23 jum.assertEquals("test23", "Passed as arguments: zero, one, two.", ps2); 25 24 … … 27 26 try{ 28 27 // Missing a required parameter 29 var ps4 = dojo.string.substitute Params(tplb, "zero", "one");28 var ps4 = dojo.string.substitute(tplb, ["zero", "one"]); 30 29 }catch(e){ 31 30 thrown = e; // exception must be thrown