add simple string formating
This commit is contained in:
parent
df324f8efa
commit
fae9a7e541
1 changed files with 11 additions and 1 deletions
|
@ -1174,6 +1174,16 @@ Encoding functions
|
|||
Format functions
|
||||
================================================================================
|
||||
*/
|
||||
Ox.format = function (s, args) {
|
||||
/* Python(ish) string formatting:
|
||||
* >>> format('{0}', ['zzz'])
|
||||
* "zzz"
|
||||
* >>> format('{x}', {x: 1})
|
||||
* "1"
|
||||
*/
|
||||
var re = /\{([^}]+)\}/g;
|
||||
return s.replace(re, function(_, match){ return args[match]; });
|
||||
}
|
||||
|
||||
Ox.formatDate = function() {
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue