diff options
author | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
commit | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch) | |
tree | c51112223ceb9121cd595a60335eb2795215590f /imports/codemirror/mode/jinja2/jinja2.js | |
parent | fcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff) | |
parent | 053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff) | |
download | ninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz |
Merge branch 'pentool' into brushtool
Conflicts:
imports/codemirror/mode/scheme/scheme.js
js/tools/BrushTool.js
Diffstat (limited to 'imports/codemirror/mode/jinja2/jinja2.js')
-rwxr-xr-x | imports/codemirror/mode/jinja2/jinja2.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/imports/codemirror/mode/jinja2/jinja2.js b/imports/codemirror/mode/jinja2/jinja2.js new file mode 100755 index 00000000..75419d84 --- /dev/null +++ b/imports/codemirror/mode/jinja2/jinja2.js | |||
@@ -0,0 +1,42 @@ | |||
1 | CodeMirror.defineMode("jinja2", function(config, parserConf) { | ||
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"); | ||
6 | |||
7 | function tokenBase (stream, state) { | ||
8 | var ch = stream.next(); | ||
9 | if (ch == "{") { | ||
10 | if (ch = stream.eat(/\{|%|#/)) { | ||
11 | stream.eat("-"); | ||
12 | state.tokenize = inTag(ch); | ||
13 | return "tag"; | ||
14 | } | ||
15 | } | ||
16 | } | ||
17 | function inTag (close) { | ||
18 | if (close == "{") { | ||
19 | close = "}"; | ||
20 | } | ||
21 | return function (stream, state) { | ||
22 | var ch = stream.next(); | ||
23 | if ((ch == close || (ch == "-" && stream.eat(close))) | ||
24 | && stream.eat("}")) { | ||
25 | state.tokenize = tokenBase; | ||
26 | return "tag"; | ||
27 | } | ||
28 | if (stream.match(keywords)) { | ||
29 | return "keyword"; | ||
30 | } | ||
31 | return close == "#" ? "comment" : "string"; | ||
32 | }; | ||
33 | } | ||
34 | return { | ||
35 | startState: function () { | ||
36 | return {tokenize: tokenBase}; | ||
37 | }, | ||
38 | token: function (stream, state) { | ||
39 | return state.tokenize(stream, state); | ||
40 | } | ||
41 | }; | ||
42 | }); | ||