Sha256: 52f3063afee7de36b34accaea03e14b3ac6d7ab7d77eaf2c7e8a84808e4232a9

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

CodeMirror.defineMode("jinja2", function() {
    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

6 entries across 4 versions & 2 rubygems

Version Path
codemirror-rails-3.02 vendor/assets/javascripts/codemirror/modes/jinja2.js
swagr-0.0.10 examples/examples01/static/js/codemirror/mode/jinja2/jinja2.js
swagr-0.0.10 templates/static/js/codemirror/mode/jinja2/jinja2.js
swagr-0.0.8 examples/examples01/static/js/codemirror/mode/jinja2/jinja2.js
swagr-0.0.8 templates/static/js/codemirror/mode/jinja2/jinja2.js
codemirror-rails-3.00 vendor/assets/javascripts/codemirror/modes/jinja2.js