add $.format
This commit is contained in:
parent
6c79e85e8c
commit
80f1a3a071
3 changed files with 21 additions and 1 deletions
|
|
@ -52,6 +52,7 @@
|
|||
"public/js/lib/bootstrap.min.js",
|
||||
"public/js/lib/nprogress.js",
|
||||
"public/js/lib/beautify-html.js",
|
||||
"public/js/frappe/format.js",
|
||||
|
||||
"public/js/frappe/provide.js",
|
||||
"public/js/frappe/class.js",
|
||||
|
|
|
|||
19
frappe/public/js/frappe/format.js
Normal file
19
frappe/public/js/frappe/format.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
function format (str, args) {
|
||||
this.unkeyed_index = 0;
|
||||
return str.replace(/\{(\w*)\}/g, function(match, key) {
|
||||
|
||||
if (key === '') {
|
||||
key = this.unkeyed_index;
|
||||
this.unkeyed_index++
|
||||
}
|
||||
if (key == +key) {
|
||||
return args[key] !== undefined
|
||||
? args[key]
|
||||
: match;
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
if (jQuery) {
|
||||
jQuery.format = format
|
||||
}
|
||||
|
|
@ -247,4 +247,4 @@ frappe.utils = {
|
|||
setTimeout(function() { callback(dataURL); }, 10 );
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue