source: frontend/node_modules/tmpl/lib/tmpl.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 564 bytes
RevLine 
[9af201e]1var INTERPOLATE = /{([^{]+?)}/g
2
3module.exports = function(str, data) {
4 var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
5 'with(obj||{}){__p.push(\'' +
6 str.replace(/\\/g, '\\\\')
7 .replace(/'/g, "\\'")
8 .replace(INTERPOLATE, function(match, code) {
9 return "'," + code.replace(/\\'/g, "'") + ",'"
10 })
11 .replace(/\r/g, '\\r')
12 .replace(/\n/g, '\\n')
13 .replace(/\t/g, '\\t')
14 + "');}return __p.join('');"
15 var func = new Function('obj', tmpl)
16 return data ? func(data) : func
17}
Note: See TracBrowser for help on using the repository browser.