Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions lib/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,9 @@ string.js - Copyright (C) 2012-2014, JP Richardson <[email protected]>
var opening = opening || Export.TMPL_OPEN
var closing = closing || Export.TMPL_CLOSE

var open = opening.replace(/[-[\]()*\s]/g, "\\$&").replace(/\$/g, '\\$')
var close = closing.replace(/[-[\]()*\s]/g, "\\$&").replace(/\$/g, '\\$')
var r = new RegExp(open + '(.+?)' + close, 'g')
//, r = /\{\{(.+?)\}\}/g
var matches = s.match(r) || [];

matches.forEach(function(match) {
var key = match.substring(opening.length, match.length - closing.length);//chop {{ and }}
if (typeof values[key] != 'undefined')
s = s.replace(match, values[key]);
var re = new RegExp(opening.replace(/([^a-z])/gi,'\\$1')+'(.*?)'+closing.replace(/([^a-z])/gi,'\\$1'), 'g');
s = s.replace(re, function(all,key) {
return values[key]!==undefined ? values[key] : all
});
return new this.constructor(s);
},
Expand Down