Sha256: 0915fce79505ef8d68dd3800877f11c4bee9b67ba96293609fc453df0b7f16a9

Contents?: true

Size: 1.35 KB

Versions: 262

Compression:

Stored size: 1.35 KB

Contents

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);
        }
    }; 
});

Version data entries

262 entries across 262 versions & 9 rubygems

Version Path
marty-2.4.7 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.4.6 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.4.5 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.4.4 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.4.3 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.4.2 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.4.1 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.4.0 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.15 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.14 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.13 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.12 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.11 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.10 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.9 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.8 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.7 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.5 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.3.4 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-2.1.5 app/components/marty/script_form/client/mode/jinja2/jinja2.js