soy.js (CodeMirror-5.58.2) | : | soy.js (CodeMirror-5.58.3) | ||
---|---|---|---|---|
skipping to change at line 19 | skipping to change at line 19 | |||
else // Plain browser env | else // Plain browser env | |||
mod(CodeMirror); | mod(CodeMirror); | |||
})(function(CodeMirror) { | })(function(CodeMirror) { | |||
"use strict"; | "use strict"; | |||
var paramData = { noEndTag: true, soyState: "param-def" }; | var paramData = { noEndTag: true, soyState: "param-def" }; | |||
var tags = { | var tags = { | |||
"alias": { noEndTag: true }, | "alias": { noEndTag: true }, | |||
"delpackage": { noEndTag: true }, | "delpackage": { noEndTag: true }, | |||
"namespace": { noEndTag: true, soyState: "namespace-def" }, | "namespace": { noEndTag: true, soyState: "namespace-def" }, | |||
"@attribute": paramData, | ||||
"@attribute?": paramData, | ||||
"@param": paramData, | "@param": paramData, | |||
"@param?": paramData, | "@param?": paramData, | |||
"@inject": paramData, | "@inject": paramData, | |||
"@inject?": paramData, | "@inject?": paramData, | |||
"@state": paramData, | "@state": paramData, | |||
"template": { soyState: "templ-def", variableScope: true}, | "template": { soyState: "templ-def", variableScope: true}, | |||
"literal": { }, | "literal": { }, | |||
"msg": {}, | "msg": {}, | |||
"fallbackmsg": { noEndTag: true, reduceIndent: true}, | "fallbackmsg": { noEndTag: true, reduceIndent: true}, | |||
"select": {}, | "select": {}, | |||
skipping to change at line 56 | skipping to change at line 58 | |||
"element": { variableScope: true }, | "element": { variableScope: true }, | |||
}; | }; | |||
var indentingTags = Object.keys(tags).filter(function(tag) { | var indentingTags = Object.keys(tags).filter(function(tag) { | |||
return !tags[tag].noEndTag || tags[tag].reduceIndent; | return !tags[tag].noEndTag || tags[tag].reduceIndent; | |||
}); | }); | |||
CodeMirror.defineMode("soy", function(config) { | CodeMirror.defineMode("soy", function(config) { | |||
var textMode = CodeMirror.getMode(config, "text/plain"); | var textMode = CodeMirror.getMode(config, "text/plain"); | |||
var modes = { | var modes = { | |||
html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFac tor: 2, multilineTagIndentPastTag: false}), | html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFac tor: 2, multilineTagIndentPastTag: false, allowMissingTagName: true}), | |||
attributes: textMode, | attributes: textMode, | |||
text: textMode, | text: textMode, | |||
uri: textMode, | uri: textMode, | |||
trusted_resource_uri: textMode, | trusted_resource_uri: textMode, | |||
css: CodeMirror.getMode(config, "text/css"), | css: CodeMirror.getMode(config, "text/css"), | |||
js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit}) | js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit}) | |||
}; | }; | |||
function last(array) { | function last(array) { | |||
return array[array.length - 1]; | return array[array.length - 1]; | |||
skipping to change at line 277 | skipping to change at line 279 | |||
case "namespace-def": | case "namespace-def": | |||
if (match = stream.match(/^\.?([\w\.]+)/)) { | if (match = stream.match(/^\.?([\w\.]+)/)) { | |||
state.soyState.pop(); | state.soyState.pop(); | |||
return "variable"; | return "variable"; | |||
} | } | |||
stream.next(); | stream.next(); | |||
return null; | return null; | |||
case "param-def": | case "param-def": | |||
if (match = stream.match(/^\*/)) { | ||||
state.soyState.pop(); | ||||
state.soyState.push("param-type"); | ||||
return "type"; | ||||
} | ||||
if (match = stream.match(/^\w+/)) { | if (match = stream.match(/^\w+/)) { | |||
state.variables = prepend(state.variables, match[0]); | state.variables = prepend(state.variables, match[0]); | |||
state.soyState.pop(); | state.soyState.pop(); | |||
state.soyState.push("param-type"); | state.soyState.push("param-type"); | |||
return "def"; | return "def"; | |||
} | } | |||
stream.next(); | stream.next(); | |||
return null; | return null; | |||
case "param-ref": | case "param-ref": | |||
skipping to change at line 494 | skipping to change at line 501 | |||
} | } | |||
state.localStates.push({ | state.localStates.push({ | |||
mode: mode, | mode: mode, | |||
state: CodeMirror.startState(mode) | state: CodeMirror.startState(mode) | |||
}); | }); | |||
} | } | |||
return "attribute"; | return "attribute"; | |||
} | } | |||
return expression(stream, state); | return expression(stream, state); | |||
case "template-call-expression": | ||||
if (stream.match(/^([\w-?]+)(?==)/)) { | ||||
return "attribute"; | ||||
} else if (stream.eat('>')) { | ||||
state.soyState.pop(); | ||||
return "keyword"; | ||||
} else if (stream.eat('/>')) { | ||||
state.soyState.pop(); | ||||
return "keyword"; | ||||
} | ||||
return expression(stream, state); | ||||
case "literal": | case "literal": | |||
if (stream.match(/^(?=\{\/literal})/)) { | if (stream.match(/^(?=\{\/literal})/)) { | |||
state.soyState.pop(); | state.soyState.pop(); | |||
return this.token(stream, state); | return this.token(stream, state); | |||
} | } | |||
return tokenUntil(stream, state, /\{\/literal}/); | return tokenUntil(stream, state, /\{\/literal}/); | |||
} | } | |||
if (stream.match(/^\{literal}/)) { | if (stream.match(/^\{literal}/)) { | |||
state.indent += config.indentUnit; | state.indent += config.indentUnit; | |||
skipping to change at line 559 | skipping to change at line 577 | |||
// Not a tag-keyword; it's an implicit print tag. | // Not a tag-keyword; it's an implicit print tag. | |||
} else if (stream.eat('{')) { | } else if (stream.eat('{')) { | |||
state.tag = "print"; | state.tag = "print"; | |||
state.indent += 2 * config.indentUnit; | state.indent += 2 * config.indentUnit; | |||
state.soyState.push("tag"); | state.soyState.push("tag"); | |||
return "keyword"; | return "keyword"; | |||
} else if (!state.context && stream.match(/\bimport\b/)) { | } else if (!state.context && stream.match(/\bimport\b/)) { | |||
state.soyState.push("import"); | state.soyState.push("import"); | |||
state.indent += 2 * config.indentUnit; | state.indent += 2 * config.indentUnit; | |||
return "keyword"; | return "keyword"; | |||
} else if (match = stream.match(/^<\{/)) { | ||||
state.soyState.push("template-call-expression"); | ||||
state.tag = "print"; | ||||
state.indent += 2 * config.indentUnit; | ||||
state.soyState.push("tag"); | ||||
return "keyword"; | ||||
} else if (match = stream.match(/^<\/>/)) { | ||||
state.indent -= 2 * config.indentUnit; | ||||
return "keyword"; | ||||
} | } | |||
return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); | return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); | |||
}, | }, | |||
indent: function(state, textAfter, line) { | indent: function(state, textAfter, line) { | |||
var indent = state.indent, top = last(state.soyState); | var indent = state.indent, top = last(state.soyState); | |||
if (top == "comment") return CodeMirror.Pass; | if (top == "comment") return CodeMirror.Pass; | |||
if (top == "literal") { | if (top == "literal") { | |||
End of changes. 5 change blocks. | ||||
1 lines changed or deleted | 28 lines changed or added |