bigbiff | d006b30 | 2015-03-06 18:36:03 -0500 | [diff] [blame] | 1 | module.exports = function Templater(){ |
2 | var self = this; | ||||
3 | |||||
4 | var templatePattern = /\{(.*?)\}/g; | ||||
5 | |||||
6 | self.setTemplatePattern = function(newTemplatePattern){ | ||||
7 | templatePattern = newTemplatePattern; | ||||
8 | }; | ||||
9 | |||||
10 | self.render = function(t, data){ | ||||
11 | return t.replace(templatePattern, function(match, prop) { | ||||
12 | return data[prop] || match; | ||||
13 | }); | ||||
14 | }; | ||||
15 | }; |