[PATCH 07 of 20] hgweb: add format javascript function
Alexander Plavin
alexander at plav.in
Fri Aug 9 18:57:32 UTC 2013
# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1376046093 -14400
# Fri Aug 09 15:01:33 2013 +0400
# Node ID f112e78a72dab869d57cad83ab40ece62163d517
# Parent 8bd7e833e3be398d1932bb51b3bfa462531414b2
hgweb: add format javascript function
It replaces placeholders like '%key%' with replacement values given.
diff -r 8bd7e833e3be -r f112e78a72da mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js Fri Aug 09 14:54:43 2013 +0400
+++ b/mercurial/templates/static/mercurial.js Fri Aug 09 15:01:33 2013 +0400
@@ -293,3 +293,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