changeset 19739:5bdc179e58c1

hgweb: add format javascript function It replaces placeholders like '%key%' with replacement values given.
author Alexander Plavin <alexander@plav.in>
date Fri, 06 Sep 2013 13:30:57 +0400
parents 93b8544c4482
children 2228bd109706
files mercurial/templates/static/mercurial.js
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templates/static/mercurial.js	Fri Sep 06 13:30:57 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Fri Sep 06 13:30:57 2013 +0400
@@ -298,3 +298,9 @@
 
     setLinewrap(!getLinewrap());
 }
+
+function format(str, replacements) {
+    return str.replace(/%(\w+)%/g, function(match, p1) {
+        return String(replacements[p1]);
+    });
+}