-
Notifications
You must be signed in to change notification settings - Fork 0
/
jinjs.js
68 lines (49 loc) · 1.34 KB
/
jinjs.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
var Jinjs = function(template, context, environment) {
if (environment === undefined) {
environment = Jinjs.defaultEnvironment;
}
context = new Jinjs.Context(context);
template = new Jinjs.Template(environment, template);
return template.render(context);
};
Jinjs.Macro = function(env, func, name, args) {
};
Jinjs.templates = {};
Jinjs.Environment = function(loader) {
this.loader = loader === undefined ? Jinjs.templates : loader;
};
Jinjs.Environment.prototype.get_template = function(name) {
return this.loader[name];
};
Jinjs.Template = function(environment, template) {
this.environment = environment;
this.template = template;
this.renderFunc = template.renderFunc;
this.blocks = template.blocks;
};
Jinjs.Template.prototype.render = function(context) {
var result = [];
this.renderFunc(this.environment, context, result);
return result.join();
};
Jinjs.defaultEnvironment = new Jinjs.Environment();
Jinjs.Context = function(context) {
this.context = context;
this.blocks = {};
};
Jinjs.Context.prototype['super'] = function() {
};
Jinjs.BlockReference = function(context) {
var obj = function() {
};
obj['super'] = function() {
};
return obj;
};
Jinjs.TemplateReference = function(context) {
for (var name in context.blocks) {
if (context.blocks.hasOwnProperty(name)) {
this[name] = context.blocks[name];
}
}
};