From patchwork Sat Aug 17 22:28:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,6,V2] hgweb: add format javascript function From: Alexander Plavin X-Patchwork-Id: 2202 Message-Id: <9a094911541a650e3b3e.1376778536@debian-alexander.dolgopa> To: mercurial-devel@selenic.com Date: Sun, 18 Aug 2013 02:28:56 +0400 # HG changeset patch # User Alexander Plavin # 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. 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]); + }); +}