From db8c6bb5e8e5d9471b9de706e516b8fcfcdde91a Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Wed, 12 Oct 2016 13:18:24 -0600 Subject: [PATCH] Support python-like token replacement and formatting --- js/util/token.js | 6 +++--- package.json | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/util/token.js b/js/util/token.js index 814c070bf5b..a564a3c0d7a 100644 --- a/js/util/token.js +++ b/js/util/token.js @@ -2,6 +2,8 @@ module.exports = resolveTokens; +var stringFormat = require('string-format'); + /** * Replace tokens in a string template with values in an object * @@ -11,7 +13,5 @@ module.exports = resolveTokens; * @private */ function resolveTokens(properties, text) { - return text.replace(/{([^{}]+)}/g, function(match, key) { - return key in properties ? properties[key] : ''; - }); + return stringFormat(text, properties); } diff --git a/package.json b/package.json index 78b39ac5088..e2427b2ef3c 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "quickselect": "^1.0.0", "request": "^2.39.0", "shelf-pack": "^1.0.0", + "string-format": "^0.5.0", "supercluster": "^2.0.1", "tinyqueue": "^1.1.0", "unassertify": "^2.0.0",