Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/twig
File: twig.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"), require("../../addon/mode/multiplex"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror", "../../addon/mode/multiplex"], mod);
[7] Fix | Delete
else // Plain browser env
[8] Fix | Delete
mod(CodeMirror);
[9] Fix | Delete
})(function(CodeMirror) {
[10] Fix | Delete
"use strict";
[11] Fix | Delete
[12] Fix | Delete
CodeMirror.defineMode("twig:inner", function() {
[13] Fix | Delete
var keywords = ["and", "as", "autoescape", "endautoescape", "block", "do", "endblock", "else", "elseif", "extends", "for", "endfor", "embed", "endembed", "filter", "endfilter", "flush", "from", "if", "endif", "in", "is", "include", "import", "not", "or", "set", "spaceless", "endspaceless", "with", "endwith", "trans", "endtrans", "blocktrans", "endblocktrans", "macro", "endmacro", "use", "verbatim", "endverbatim"],
[14] Fix | Delete
operator = /^[+\-*&%=<>!?|~^]/,
[15] Fix | Delete
sign = /^[:\[\(\{]/,
[16] Fix | Delete
atom = ["true", "false", "null", "empty", "defined", "divisibleby", "divisible by", "even", "odd", "iterable", "sameas", "same as"],
[17] Fix | Delete
number = /^(\d[+\-\*\/])?\d+(\.\d+)?/;
[18] Fix | Delete
[19] Fix | Delete
keywords = new RegExp("((" + keywords.join(")|(") + "))\\b");
[20] Fix | Delete
atom = new RegExp("((" + atom.join(")|(") + "))\\b");
[21] Fix | Delete
[22] Fix | Delete
function tokenBase (stream, state) {
[23] Fix | Delete
var ch = stream.peek();
[24] Fix | Delete
[25] Fix | Delete
//Comment
[26] Fix | Delete
if (state.incomment) {
[27] Fix | Delete
if (!stream.skipTo("#}")) {
[28] Fix | Delete
stream.skipToEnd();
[29] Fix | Delete
} else {
[30] Fix | Delete
stream.eatWhile(/\#|}/);
[31] Fix | Delete
state.incomment = false;
[32] Fix | Delete
}
[33] Fix | Delete
return "comment";
[34] Fix | Delete
//Tag
[35] Fix | Delete
} else if (state.intag) {
[36] Fix | Delete
//After operator
[37] Fix | Delete
if (state.operator) {
[38] Fix | Delete
state.operator = false;
[39] Fix | Delete
if (stream.match(atom)) {
[40] Fix | Delete
return "atom";
[41] Fix | Delete
}
[42] Fix | Delete
if (stream.match(number)) {
[43] Fix | Delete
return "number";
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
//After sign
[47] Fix | Delete
if (state.sign) {
[48] Fix | Delete
state.sign = false;
[49] Fix | Delete
if (stream.match(atom)) {
[50] Fix | Delete
return "atom";
[51] Fix | Delete
}
[52] Fix | Delete
if (stream.match(number)) {
[53] Fix | Delete
return "number";
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
if (state.instring) {
[58] Fix | Delete
if (ch == state.instring) {
[59] Fix | Delete
state.instring = false;
[60] Fix | Delete
}
[61] Fix | Delete
stream.next();
[62] Fix | Delete
return "string";
[63] Fix | Delete
} else if (ch == "'" || ch == '"') {
[64] Fix | Delete
state.instring = ch;
[65] Fix | Delete
stream.next();
[66] Fix | Delete
return "string";
[67] Fix | Delete
} else if (stream.match(state.intag + "}") || stream.eat("-") && stream.match(state.intag + "}")) {
[68] Fix | Delete
state.intag = false;
[69] Fix | Delete
return "tag";
[70] Fix | Delete
} else if (stream.match(operator)) {
[71] Fix | Delete
state.operator = true;
[72] Fix | Delete
return "operator";
[73] Fix | Delete
} else if (stream.match(sign)) {
[74] Fix | Delete
state.sign = true;
[75] Fix | Delete
} else {
[76] Fix | Delete
if (stream.eat(" ") || stream.sol()) {
[77] Fix | Delete
if (stream.match(keywords)) {
[78] Fix | Delete
return "keyword";
[79] Fix | Delete
}
[80] Fix | Delete
if (stream.match(atom)) {
[81] Fix | Delete
return "atom";
[82] Fix | Delete
}
[83] Fix | Delete
if (stream.match(number)) {
[84] Fix | Delete
return "number";
[85] Fix | Delete
}
[86] Fix | Delete
if (stream.sol()) {
[87] Fix | Delete
stream.next();
[88] Fix | Delete
}
[89] Fix | Delete
} else {
[90] Fix | Delete
stream.next();
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
}
[94] Fix | Delete
return "variable";
[95] Fix | Delete
} else if (stream.eat("{")) {
[96] Fix | Delete
if (ch = stream.eat("#")) {
[97] Fix | Delete
state.incomment = true;
[98] Fix | Delete
if (!stream.skipTo("#}")) {
[99] Fix | Delete
stream.skipToEnd();
[100] Fix | Delete
} else {
[101] Fix | Delete
stream.eatWhile(/\#|}/);
[102] Fix | Delete
state.incomment = false;
[103] Fix | Delete
}
[104] Fix | Delete
return "comment";
[105] Fix | Delete
//Open tag
[106] Fix | Delete
} else if (ch = stream.eat(/\{|%/)) {
[107] Fix | Delete
//Cache close tag
[108] Fix | Delete
state.intag = ch;
[109] Fix | Delete
if (ch == "{") {
[110] Fix | Delete
state.intag = "}";
[111] Fix | Delete
}
[112] Fix | Delete
stream.eat("-");
[113] Fix | Delete
return "tag";
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
stream.next();
[117] Fix | Delete
};
[118] Fix | Delete
[119] Fix | Delete
return {
[120] Fix | Delete
startState: function () {
[121] Fix | Delete
return {};
[122] Fix | Delete
},
[123] Fix | Delete
token: function (stream, state) {
[124] Fix | Delete
return tokenBase(stream, state);
[125] Fix | Delete
}
[126] Fix | Delete
};
[127] Fix | Delete
});
[128] Fix | Delete
[129] Fix | Delete
CodeMirror.defineMode("twig", function(config, parserConfig) {
[130] Fix | Delete
var twigInner = CodeMirror.getMode(config, "twig:inner");
[131] Fix | Delete
if (!parserConfig || !parserConfig.base) return twigInner;
[132] Fix | Delete
return CodeMirror.multiplexingMode(
[133] Fix | Delete
CodeMirror.getMode(config, parserConfig.base), {
[134] Fix | Delete
open: /\{[{#%]/, close: /[}#%]\}/, mode: twigInner, parseDelimiters: true
[135] Fix | Delete
}
[136] Fix | Delete
);
[137] Fix | Delete
});
[138] Fix | Delete
CodeMirror.defineMIME("text/x-twig", "twig");
[139] Fix | Delete
});
[140] Fix | Delete
[141] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function