From 99f904adcc37d93c90defcd8ce898598e25be212 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 11 Mar 2015 16:55:04 +0100 Subject: Lot of plugins --- .../lib/CodeMirror-2.3/mode/jinja2/jinja2.js | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 codemirror_ui/lib/CodeMirror-2.3/mode/jinja2/jinja2.js (limited to 'codemirror_ui/lib/CodeMirror-2.3/mode/jinja2/jinja2.js') diff --git a/codemirror_ui/lib/CodeMirror-2.3/mode/jinja2/jinja2.js b/codemirror_ui/lib/CodeMirror-2.3/mode/jinja2/jinja2.js new file mode 100644 index 0000000..75419d8 --- /dev/null +++ b/codemirror_ui/lib/CodeMirror-2.3/mode/jinja2/jinja2.js @@ -0,0 +1,42 @@ +CodeMirror.defineMode("jinja2", function(config, parserConf) { + var keywords = ["block", "endblock", "for", "endfor", "in", "true", "false", + "loop", "none", "self", "super", "if", "as", "not", "and", + "else", "import", "with", "without", "context"]; + keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b"); + + function tokenBase (stream, state) { + var ch = stream.next(); + if (ch == "{") { + if (ch = stream.eat(/\{|%|#/)) { + stream.eat("-"); + state.tokenize = inTag(ch); + return "tag"; + } + } + } + function inTag (close) { + if (close == "{") { + close = "}"; + } + return function (stream, state) { + var ch = stream.next(); + if ((ch == close || (ch == "-" && stream.eat(close))) + && stream.eat("}")) { + state.tokenize = tokenBase; + return "tag"; + } + if (stream.match(keywords)) { + return "keyword"; + } + return close == "#" ? "comment" : "string"; + }; + } + return { + startState: function () { + return {tokenize: tokenBase}; + }, + token: function (stream, state) { + return state.tokenize(stream, state); + } + }; +}); -- cgit v1.2.3