Sha256: 21e2c93020664c505e41eb8d8a4c5994bbb9ab9021764160d8de71b2c08e06c7
Contents?: true
Size: 566 Bytes
Versions: 9
Compression:
Stored size: 566 Bytes
Contents
var INTERPOLATE = /{([\s\S]+?)}/g module.exports = function(str, data) { var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' + 'with(obj||{}){__p.push(\'' + str.replace(/\\/g, '\\\\') .replace(/'/g, "\\'") .replace(INTERPOLATE, function(match, code) { return "'," + code.replace(/\\'/g, "'") + ",'" }) .replace(/\r/g, '\\r') .replace(/\n/g, '\\n') .replace(/\t/g, '\\t') + "');}return __p.join('');" var func = new Function('obj', tmpl) return data ? func(data) : func }
Version data entries
9 entries across 9 versions & 3 rubygems