[PATCH 1 of 5] hgweb: add format javascript function
Alexander Plavin
alexander at plav.in
Wed Sep 18 18:33:15 UTC 2013
# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1378459857 -14400
# Fri Sep 06 13:30:57 2013 +0400
# Node ID 1a20a7cc2b08c3b720ac02df815905e01276a90a
# Parent 17e983fb2af3e26e989d31129d8bbc31e4423210
hgweb: add format javascript function
It replaces placeholders like '%key%' with replacement values given.
diff -r 17e983fb2af3 -r 1a20a7cc2b08 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]);
+ });
+}
More information about the Mercurial-devel
mailing list