'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var escape = require('./escape');
var defaults = require('./defaults');
var escapeJsStr = require('./escapeJsStr');
 
var regMatcher = /<%-([\s\S]+?)%>|<%=([\s\S]+?)%>|<%([\s\S]+?)%>|$/g;
exports = function(str, util) {
    if (!util) {
        util =
            typeof _ === 'object'
                ? _
                : {
                      escape: escape
                  };
    } else {
        defaults(util, {
            escape: escape
        });
    }
    var index = 0;
    var src = "__p+='";
    str.replace(regMatcher, function(
        match,
        escape,
        interpolate,
        evaluate,
        offset
    ) {
        src += escapeJsStr(str.slice(index, offset));
        index = offset + match.length;
        if (escape) {
            src += "'+\n((__t=(".concat(
                escape,
                "))==null?'':util.escape(__t))+\n'"
            );
        } else if (interpolate) {
            src += "'+\n((__t=(".concat(interpolate, "))==null?'':__t)+\n'");
        } else if (evaluate) {
            src += "';\n".concat(evaluate, "\n__p+='");
        }
        return match;
    });
    src += "';\n";
    src = 'with(obj||{}){\n'.concat(src, '}\n');
    src = "var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n".concat(
        src,
        'return __p;\n'
    );
    var render = new Function('obj', 'util', src);
    return function(data) {
        return render.call(null, data, util);
    };
};
 
module.exports = exports;