Patchwork [1,of,6,V2] hgweb: add format javascript function

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 17, 2013, 10:28 p.m.
Message ID <9a094911541a650e3b3e.1376778536@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2202/
State Superseded
Commit 5bdc179e58c13d7d37e2c77af4904c1ef4edf0ef
Headers show

Comments

Alexander Plavin - Aug. 17, 2013, 10:28 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376046093 -14400
#      Fri Aug 09 15:01:33 2013 +0400
# Node ID 9a094911541a650e3b3e84eef5d3ed46a24cb74e
# Parent  ae42151fc56ecc420f3fac291110a81476609b22
hgweb: add format javascript function

It replaces placeholders like '%key%' with replacement values given.

Patch

diff -r ae42151fc56e -r 9a094911541a mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Sat Aug 17 15:33:25 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Fri Aug 09 15:01:33 2013 +0400
@@ -298,3 +298,9 @@ 
 
     setLinewrap(!getLinewrap());
 }
+
+function format(str, replacements) {
+    return str.replace(/%(\w+)%/g, function(match, p1) {
+        return String(replacements[p1]);
+    });
+}