install-nix-action/node_modules/tmpl/lib/tmpl.js
Domen Kožar 70742d22d9
v6
2019-11-19 17:50:30 +01:00

17 lines
566 B
JavaScript

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
}