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-1.0.51 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.50 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.48 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.47 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.46 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.44 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.43 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.42 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.41 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.39 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.38 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.37 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.36 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.35 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.34 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.33 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.32 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.31 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.30 app/components/marty/script_form/client/mode/jinja2/jinja2.js
marty-1.0.29 app/components/marty/script_form/client/mode/jinja2/jinja2.js