Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
malwaredllc
GitHub Repository: malwaredllc/byob
Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/mode/jinja2/jinja2.js
1294 views
1
CodeMirror.defineMode("jinja2", function() {
2
var keywords = ["and", "as", "block", "endblock", "by", "cycle", "debug", "else", "elif",
3
"extends", "filter", "endfilter", "firstof", "for",
4
"endfor", "if", "endif", "ifchanged", "endifchanged",
5
"ifequal", "endifequal", "ifnotequal",
6
"endifnotequal", "in", "include", "load", "not", "now", "or",
7
"parsed", "regroup", "reversed", "spaceless",
8
"endspaceless", "ssi", "templatetag", "openblock",
9
"closeblock", "openvariable", "closevariable",
10
"openbrace", "closebrace", "opencomment",
11
"closecomment", "widthratio", "url", "with", "endwith",
12
"get_current_language", "trans", "noop", "blocktrans",
13
"endblocktrans", "get_available_languages",
14
"get_current_language_bidi", "plural"];
15
keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");
16
17
function tokenBase (stream, state) {
18
var ch = stream.next();
19
if (ch == "{") {
20
if (ch = stream.eat(/\{|%|#/)) {
21
stream.eat("-");
22
state.tokenize = inTag(ch);
23
return "tag";
24
}
25
}
26
}
27
function inTag (close) {
28
if (close == "{") {
29
close = "}";
30
}
31
return function (stream, state) {
32
var ch = stream.next();
33
if ((ch == close || (ch == "-" && stream.eat(close)))
34
&& stream.eat("}")) {
35
state.tokenize = tokenBase;
36
return "tag";
37
}
38
if (stream.match(keywords)) {
39
return "keyword";
40
}
41
return close == "#" ? "comment" : "string";
42
};
43
}
44
return {
45
startState: function () {
46
return {tokenize: tokenBase};
47
},
48
token: function (stream, state) {
49
return state.tokenize(stream, state);
50
}
51
};
52
});
53
54