var Template = new Class({ Implements: Options, options: { 'before': '%', 'after': '%' }, initialize: function(string, options){ this.string = string; this.setOptions(options); this.regExp = new RegExp(this.options.before.escapeRegExp() + '([\\w-]+)' + this.options.after.escapeRegExp(), 'g'); }, parse: function(data){ var options = this.options; return this.string.replace(this.regExp, function(match){ return $pick(data[match.substring(options.before.length, match.length - options.after.length)], ''); }); } });