hgweb: add format javascript function
authorAlexander Plavin <alexander@plav.in>
Fri, 06 Sep 2013 13:30:57 +0400
changeset 19739 5bdc179e58c1
parent 19738 93b8544c4482
child 19740 2228bd109706
hgweb: add format javascript function It replaces placeholders like '%key%' with replacement values given.
mercurial/templates/static/mercurial.js
--- 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]);
+    });
+}