-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
103 lines (86 loc) · 2.6 KB
/
index.js
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Generated by CoffeeScript 1.12.7
(function() {
var __express, cacheless_engine, e, engine, getCommonHeaders, getCommonHeadersJs, ref, to_express, view;
engine = require('./lib/engine').engine;
ref = require('./lib/view'), view = ref.view, getCommonHeaders = ref.getCommonHeaders, getCommonHeadersJs = ref.getCommonHeadersJs;
exports.engine = engine;
exports.view = view;
exports.getCommonHeaders = getCommonHeaders;
exports.getCommonHeadersJs = getCommonHeadersJs;
exports.expressEngine = e = new engine({
verbose: false,
prettyPrintErrors: true
});
exports.render = e.run;
cacheless_engine = new engine({
verbose: false,
prettyPrintErrors: true,
cache: false
});
exports.compileStr = function(template_str, options) {
var v;
v = new view(template_str, options);
return function(x) {
return v.run(x);
};
};
to_express = exports.toExpress = function(eng) {
return function(filename, options, cb) {
return eng.run(filename, options, function(err, res) {
if (err) {
if (typeof err === "string") {
err = new Error(err);
}
return cb(err);
} else {
return cb(null, res);
}
});
};
};
__express = exports.__express = to_express(e);
exports.__consolidate_engine_render = function(filename, options, cb) {
var eng;
eng = options.cache ? e : cacheless_engine;
return eng.run(filename, options, function(err, res) {
return cb(err, res);
});
};
exports.str_render = exports.strRender = function(template_str, options, cb) {
var err, ref1, res, v;
v = new view(template_str, options);
ref1 = v.run(options), err = ref1[0], res = ref1[1];
return cb(err, res);
};
exports.compile = require('./lib/view').expressCompile;
exports.configurable_compile = function(source, opts) {
var err, header, output, v;
opts = opts || {};
opts.headers = opts.headers != null ? opts.headers : true;
opts.filename = opts.filename || null;
opts.to_coffee = opts.to_coffee || false;
err = null;
v = new view(source, {
filename: opts.filename,
bundlePath: opts.filename,
browserMode: true
});
if (opts.to_coffee) {
output = v.toCoffee();
} else {
output = v.toJavaScript();
}
if (v.error) {
throw v.error.e;
}
if (opts.headers) {
header = getCommonHeadersJs(true, true, true);
if (opts.coffee) {
output = "`" + header + "`\n\n" + output;
} else {
output = header + "\n;\n" + output;
}
}
return output;
};
}).call(this);