1 CodeMirror.defineMode("jinja2", function() {
2 var keywords = ["block", "endblock", "for", "endfor", "in", "true", "false",
3 "loop", "none", "self", "super", "if", "as", "not", "and",
4 "else", "import", "with", "without", "context"];
5 keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");
7 function tokenBase (stream, state) {
8 var ch = stream.next();
10 if (ch = stream.eat(/\{|%|#/)) {
12 state.tokenize = inTag(ch);
17 function inTag (close) {
21 return function (stream, state) {
22 var ch = stream.next();
23 if ((ch == close || (ch == "-" && stream.eat(close)))
25 state.tokenize = tokenBase;
28 if (stream.match(keywords)) {
31 return close == "#" ? "comment" : "string";
35 startState: function () {
36 return {tokenize: tokenBase};
38 token: function (stream, state) {
39 return state.tokenize(stream, state);