update Ox.formatUnit

This commit is contained in:
rolux 2012-07-02 16:19:36 +02:00
parent f6a767b6cb
commit 487ee4626d

View file

@ -669,7 +669,7 @@ Ox.formatString <f> Basic string formatting
> Ox.formatString('{a}{b}', {a: 'foo', b: 'bar'})
'foobar'
@*/
Ox.formatString = function (string, collection) {
Ox.formatString = function(string, collection) {
return string.replace(/\{([^}]+)\}/g, function(string, match) {
return collection[match];
});
@ -684,7 +684,7 @@ Ox.formatUnit <f> Formats a number with a unit
@*/
Ox.formatUnit = function(number, string, decimals) {
return Ox.formatNumber(number, decimals)
+ (string == '%' ? '' : ' ') + string;
+ (/^[:%]/.test(string) ? '' : ' ') + string;
};
/*@