[OpenLayers-Commits] r5164 - sandbox/ahocevar/sldRenderer/lib/OpenLayers
commits at openlayers.org
commits at openlayers.org
Fri Nov 9 17:30:37 EST 2007
Author: ahocevar
Date: 2007-11-09 17:30:34 -0500 (Fri, 09 Nov 2007)
New Revision: 5164
Modified:
sandbox/ahocevar/sldRenderer/lib/OpenLayers/BaseTypes.js
Log:
improved version of OpenLayers.String.format
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/BaseTypes.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/BaseTypes.js 2007-11-09 22:00:59 UTC (rev 5163)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/BaseTypes.js 2007-11-09 22:30:34 UTC (rev 5164)
@@ -93,8 +93,7 @@
* APIFunction: OpenLayers.String.format
* Given a string with tokens in the form ${token}, return a string
* with tokens replaced with properties from the given context
- * object. Represent a literal "${" by escaping the curly brace.
- * E.g. "$\{".
+ * object. Represent a literal "${" by doubling it, e.g. "${${".
*
* Parameters:
* template - {String} A string with tokens to be replaced. A template
@@ -118,6 +117,12 @@
if(last != -1) {
tokens[i] = context[tokens[i].substring(0, last)] +
tokens[i].substring(++last);
+ } else {
+ if (tokens[i]) {
+ tokens[i] = tokens[i] + "}";
+ } else {
+ tokens[i] = "${" + tokens[i];
+ }
}
}
return tokens.join("");
More information about the Commits
mailing list