File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/soy.tar
Back
test.js 0000644 00000025351 15030164423 0006065 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function() { var mode = CodeMirror.getMode({indentUnit: 2}, "soy"); function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} // Test of small keywords and words containing them. MT('keywords-test', '[keyword {] [keyword as] worrying [keyword and] notorious [keyword as]', ' the Fandor[operator -]alias assassin, [keyword or]', ' Corcand cannot fit [keyword in] [keyword }]'); MT('let-test', '[keyword {template] [def .name][keyword }]', ' [keyword {let] [def $name]: [string "world"][keyword /}]', ' [tag&bracket <][tag h1][tag&bracket >]', ' Hello, [keyword {][variable-2 $name][keyword }]', ' [tag&bracket </][tag h1][tag&bracket >]', '[keyword {/template}]', ''); MT('function-test', '[keyword {] [callee&variable css]([string "MyClass"])[keyword }]', '[tag&bracket <][tag input] [attribute value]=[string "]' + '[keyword {] [callee&variable index]([variable-2&error $list])[keyword }]' + '[string "][tag&bracket />]'); MT('namespace-test', '[keyword {namespace] [variable namespace][keyword }]') MT('namespace-with-attribute-test', '[keyword {namespace] [variable my.namespace.templates] ' + '[attribute requirecss]=[string "my.namespace"][keyword }]'); MT('operators-test', '[keyword {] [atom 1] [operator ==] [atom 1] [keyword }]', '[keyword {] [atom 1] [operator !=] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator +] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator -] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator *] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator /] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator %] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator <=] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator >=] [atom 2] [keyword }]', '[keyword {] [atom 3] [operator >] [atom 2] [keyword }]', '[keyword {] [atom 2] [operator >] [atom 3] [keyword }]', '[keyword {] [atom null] [operator ?:] [string ""] [keyword }]', '[keyword {] [variable-2&error $variable] [operator |] safeHtml [keyword }]') MT('primitive-test', '[keyword {] [atom true] [keyword }]', '[keyword {] [atom false] [keyword }]', '[keyword {] truethy [keyword }]', '[keyword {] falsey [keyword }]', '[keyword {] [atom 42] [keyword }]', '[keyword {] [atom .42] [keyword }]', '[keyword {] [atom 0.42] [keyword }]', '[keyword {] [atom -0.42] [keyword }]', '[keyword {] [atom -.2] [keyword }]', '[keyword {] [atom 6.03e23] [keyword }]', '[keyword {] [atom -0.03e0] [keyword }]', '[keyword {] [atom 0x1F] [keyword }]', '[keyword {] [atom 0x1F00BBEA] [keyword }]'); MT('param-type-record', '[keyword {@param] [def record]: [[[property foo]: [type bool], [property bar]: [type int] ]][keyword }]' ); MT('param-type-map', '[keyword {@param] [def unknown]: [type map]<[type string], [type bool]>[keyword }]' ); MT('param-type-list', '[keyword {@param] [def list]: [type list]<[type ?]>[keyword }]' ); MT('param-type-any', '[keyword {@param] [def unknown]: [type ?][keyword }]' ); MT('param-type-nested', '[keyword {@param] [def a]: ' + '[type list]<[[[property a]: [type int], ' + '[property b]: [type map]<[type string], ' + '[type bool]>]]>][keyword }]'); MT('undefined-var', '[keyword {][variable-2&error $var]'); MT('param-scope-test', '[keyword {template] [def .a][keyword }]', ' [keyword {@param] [def x]: [type string][keyword }]', ' [keyword {][variable-2 $x][keyword }]', '[keyword {/template}]', '', '[keyword {template] [def .b][keyword }]', ' [keyword {][variable-2&error $x][keyword }]', '[keyword {/template}]', ''); MT('if-variable-test', '[keyword {if] [variable-2&error $showThing][keyword }]', ' Yo!', '[keyword {/if}]', ''); MT('defined-if-variable-test', '[keyword {template] [def .foo][keyword }]', ' [keyword {@param?] [def showThing]: [type bool][keyword }]', ' [keyword {if] [variable-2 $showThing][keyword }]', ' Yo!', ' [keyword {/if}]', '[keyword {/template}]', ''); MT('template-calls-test', '[keyword {call] [variable-2 .foo][keyword /}]', '[keyword {call] [variable foo][keyword /}]', '[keyword {call] [variable foo][keyword }] [keyword {/call}]', '[keyword {call] [variable first1.second.third_3][keyword /}]', '[keyword {call] [variable first1.second.third_3] [keyword }] [keyword {/call}]', ''); MT('foreach-scope-test', '[keyword {@param] [def bar]: [type string][keyword }]', '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', ' [keyword {][variable-2 $foo][keyword }]', '[keyword {/foreach}]', '[keyword {][variable-2&error $foo][keyword }]', '[keyword {][variable-2 $bar][keyword }]'); MT('foreach-ifempty-indent-test', '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', ' something', '[keyword {ifempty}]', ' nothing', '[keyword {/foreach}]', ''); MT('foreach-index', '[keyword {foreach] [def $foo],[def $index] [keyword in] [[]] [keyword }]', ' [keyword {][variable-2 $foo][keyword }] [keyword {][variable-2 $index][keyword }]', '[keyword {/foreach}]'); MT('nested-kind-test', '[keyword {template] [def .foo] [attribute kind]=[string "html"][keyword }]', ' [tag&bracket <][tag div][tag&bracket >]', ' [keyword {call] [variable-2 .bar][keyword }]', ' [keyword {param] [property propertyName] [attribute kind]=[string "js"][keyword }]', ' [keyword var] [def bar] [operator =] [number 5];', ' [keyword {/param}]', ' [keyword {/call}]', ' [tag&bracket </][tag div][tag&bracket >]', '[keyword {/template}]', ''); MT('tag-starting-with-function-call-is-not-a-keyword', '[keyword {][callee&variable index]([variable-2&error $foo])[keyword }]', '[keyword {css] [string "some-class"][keyword }]', '[keyword {][callee&variable css]([string "some-class"])[keyword }]', ''); MT('allow-missing-colon-in-@param', '[keyword {template] [def .foo][keyword }]', ' [keyword {@param] [def showThing] [type bool][keyword }]', ' [keyword {if] [variable-2 $showThing][keyword }]', ' Yo!', ' [keyword {/if}]', '[keyword {/template}]', ''); MT('param-type-and-default-value', '[keyword {template] [def .foo][keyword }]', ' [keyword {@param] [def bar]: [type bool] = [atom true][keyword }]', '[keyword {/template}]', ''); MT('state-variable-reference', '[keyword {template] [def .foo][keyword }]', ' [keyword {@param] [def bar]:= [atom true][keyword }]', ' [keyword {@state] [def foobar]:= [variable-2 $bar][keyword }]', '[keyword {/template}]', ''); MT('param-type-template', '[keyword {template] [def .foo][keyword }]', ' [keyword {@param] [def renderer]: ([def s]:[type string])=>[type html][keyword }]', ' [keyword {call] [variable-2 $renderer] [keyword /}]', '[keyword {/template}]', ''); MT('single-quote-strings', '[keyword {][string "foo"] [string \'bar\'][keyword }]', ''); MT('literal-comments', '[keyword {literal}]/* comment */ // comment[keyword {/literal}]'); MT('highlight-command-at-eol', '[keyword {msg]', ' [keyword }]'); MT('switch-indent-test', '[keyword {let] [def $marbles]: [atom 5] [keyword /}]', '[keyword {switch] [variable-2 $marbles][keyword }]', ' [keyword {case] [atom 0][keyword }]', ' No marbles', ' [keyword {default}]', ' At least 1 marble', '[keyword {/switch}]', ''); MT('if-elseif-else-indent', '[keyword {if] [atom true][keyword }]', ' [keyword {let] [def $a]: [atom 5] [keyword /}]', '[keyword {elseif] [atom false][keyword }]', ' [keyword {let] [def $bar]: [atom 5] [keyword /}]', '[keyword {else}]', ' [keyword {let] [def $bar]: [atom 5] [keyword /}]', '[keyword {/if}]'); MT('msg-fallbackmsg-indent', '[keyword {msg] [attribute desc]=[string "A message"][keyword }]', ' A message', '[keyword {fallbackmsg] [attribute desc]=[string "A message"][keyword }]', ' Old message', '[keyword {/msg}]'); MT('literal-indent', '[keyword {template] [def .name][keyword }]', ' [keyword {literal}]', ' Lerum', ' [keyword {/literal}]', ' Ipsum', '[keyword {/template}]'); MT('special-chars', '[keyword {sp}]', '[keyword {nil}]', '[keyword {\\r}]', '[keyword {\\n}]', '[keyword {\\t}]', '[keyword {lb}]', '[keyword {rb}]'); MT('let-list-literal', '[keyword {let] [def $test]: [[[[[string \'a\'] ], [[[string \'b\'] ] ] [keyword /}]'); MT('let-record-literal', '[keyword {let] [def $test]: [keyword record]([property test]: [callee&variable bidiGlobalDir](), ' + '[property foo]: [atom 5]) [keyword /}]'); MT('let-map-literal', '[keyword {let] [def $test]: [keyword map]([string \'outer\']: [keyword map]([atom 5]: [atom false]), ' + '[string \'foo\']: [string \'bar\']) [keyword /}]'); MT('wrong-closing-tag', '[keyword {if] [atom true][keyword }]', ' Optional', '[keyword&error {/badend][keyword }]'); MT('list-comprehension', '[keyword {let] [def $myList]: [[[[[string \'a\'] ] ] [keyword /}] ' + '[keyword {let] [def $test]: [[[variable $a] [operator +] [atom 1] [keyword for] ' + '[def $a] [keyword in] [variable-2 $myList] [keyword if] [variable-2 $a] [operator >=] [atom 3] ] [keyword /}]'); MT('list-comprehension-index', '[keyword {let] [def $test]: [[[variable $a] [operator +] [variable $index] [keyword for] ' + '[def $a],[def $index] [keyword in] [[]] [keyword if] [variable-2 $a] [operator >=] [variable-2 $index] ] [keyword /}]'); MT('list-comprehension-variable-scope', '[keyword {let] [def $name]: [string "world"][keyword /}]', '[keyword {let] [def $test]: [[[variable $a] [operator +] [variable $index] [keyword for] ' + '[def $a],[def $index] [keyword in] [[]] [keyword if] [variable-2 $a] [operator >=] [variable-2 $index] ] [keyword /}]', '[keyword {][variable-2&error $a][keyword }]', '[keyword {][variable-2&error $index][keyword }]', '[keyword {][variable-2 $test][keyword }]', '[keyword {][variable-2 $name][keyword }]'); MT('import', '[keyword import] {[def Name], [variable Person] [keyword as] [def P]} [keyword from] [string \'examples/proto/example.proto\'];'); })(); index.html 0000644 00000003613 15030164423 0006542 0 ustar 00 <!doctype html> <title>CodeMirror: Soy (Closure Template) mode</title> <meta charset="utf-8"/> <link rel=stylesheet href="../../doc/docs.css"> <link rel="stylesheet" href="../../lib/codemirror.css"> <script src="../../lib/codemirror.js"></script> <script src="../../addon/edit/matchbrackets.js"></script> <script src="../htmlmixed/htmlmixed.js"></script> <script src="../xml/xml.js"></script> <script src="../javascript/javascript.js"></script> <script src="../css/css.js"></script> <script src="soy.js"></script> <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">Soy (Closure Template)</a> </ul> </div> <article> <h2>Soy (Closure Template) mode</h2> <form><textarea id="code" name="code"> {namespace example} /** * Says hello to the world. */ {template .helloWorld} {@param name: string} {@param? score: number} Hello <b>{$name}</b>! <div> {if $score} <em>{$score} points</em> {else} no score {/if} </div> {/template} {template .alertHelloWorld kind="js"} alert('Hello World'); {/template} </textarea></form> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, matchBrackets: true, mode: "text/x-soy", indentUnit: 2, indentWithTabs: false }); </script> <p>A mode for <a href="https://developers.google.com/closure/templates/">Closure Templates</a> (Soy).</p> <p><strong>MIME type defined:</strong> <code>text/x-soy</code>.</p> </article> soy.js 0000644 00000050524 15030164423 0005720 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var paramData = { noEndTag: true, soyState: "param-def" }; var tags = { "alias": { noEndTag: true }, "delpackage": { noEndTag: true }, "namespace": { noEndTag: true, soyState: "namespace-def" }, "@param": paramData, "@param?": paramData, "@inject": paramData, "@inject?": paramData, "@state": paramData, "template": { soyState: "templ-def", variableScope: true}, "literal": { }, "msg": {}, "fallbackmsg": { noEndTag: true, reduceIndent: true}, "select": {}, "plural": {}, "let": { soyState: "var-def" }, "if": {}, "elseif": { noEndTag: true, reduceIndent: true}, "else": { noEndTag: true, reduceIndent: true}, "switch": {}, "case": { noEndTag: true, reduceIndent: true}, "default": { noEndTag: true, reduceIndent: true}, "foreach": { variableScope: true, soyState: "for-loop" }, "ifempty": { noEndTag: true, reduceIndent: true}, "for": { variableScope: true, soyState: "for-loop" }, "call": { soyState: "templ-ref" }, "param": { soyState: "param-ref"}, "print": { noEndTag: true }, "deltemplate": { soyState: "templ-def", variableScope: true}, "delcall": { soyState: "templ-ref" }, "log": {}, "element": { variableScope: true }, }; var indentingTags = Object.keys(tags).filter(function(tag) { return !tags[tag].noEndTag || tags[tag].reduceIndent; }); CodeMirror.defineMode("soy", function(config) { var textMode = CodeMirror.getMode(config, "text/plain"); var modes = { html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false}), attributes: textMode, text: textMode, uri: textMode, trusted_resource_uri: textMode, css: CodeMirror.getMode(config, "text/css"), js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit}) }; function last(array) { return array[array.length - 1]; } function tokenUntil(stream, state, untilRegExp) { if (stream.sol()) { for (var indent = 0; indent < state.indent; indent++) { if (!stream.eat(/\s/)) break; } if (indent) return null; } var oldString = stream.string; var match = untilRegExp.exec(oldString.substr(stream.pos)); if (match) { // We don't use backUp because it backs up just the position, not the state. // This uses an undocumented API. stream.string = oldString.substr(0, stream.pos + match.index); } var result = stream.hideFirstChars(state.indent, function() { var localState = last(state.localStates); return localState.mode.token(stream, localState.state); }); stream.string = oldString; return result; } function contains(list, element) { while (list) { if (list.element === element) return true; list = list.next; } return false; } function prepend(list, element) { return { element: element, next: list }; } function popcontext(state) { if (!state.context) return; if (state.context.scope) { state.variables = state.context.scope; } state.context = state.context.previousContext; } // Reference a variable `name` in `list`. // Let `loose` be truthy to ignore missing identifiers. function ref(list, name, loose) { return contains(list, name) ? "variable-2" : (loose ? "variable" : "variable-2 error"); } // Data for an open soy tag. function Context(previousContext, tag, scope) { this.previousContext = previousContext; this.tag = tag; this.kind = null; this.scope = scope; } function expression(stream, state) { var match; if (stream.match(/[[]/)) { state.soyState.push("list-literal"); state.context = new Context(state.context, "list-literal", state.variables); state.lookupVariables = false; return null; } else if (stream.match(/map\b/)) { state.soyState.push("map-literal"); return "keyword"; } else if (stream.match(/record\b/)) { state.soyState.push("record-literal"); return "keyword"; } else if (stream.match(/([\w]+)(?=\()/)) { return "variable callee"; } else if (match = stream.match(/^["']/)) { state.soyState.push("string"); state.quoteKind = match[0]; return "string"; } else if (stream.match(/^[(]/)) { state.soyState.push("open-parentheses"); return null; } else if (stream.match(/(null|true|false)(?!\w)/) || stream.match(/0x([0-9a-fA-F]{2,})/) || stream.match(/-?([0-9]*[.])?[0-9]+(e[0-9]*)?/)) { return "atom"; } else if (stream.match(/(\||[+\-*\/%]|[=!]=|\?:|[<>]=?)/)) { // Tokenize filter, binary, null propagator, and equality operators. return "operator"; } else if (match = stream.match(/^\$([\w]+)/)) { return ref(state.variables, match[1], !state.lookupVariables); } else if (match = stream.match(/^\w+/)) { return /^(?:as|and|or|not|in|if)$/.test(match[0]) ? "keyword" : null; } stream.next(); return null; } return { startState: function() { return { soyState: [], variables: prepend(null, 'ij'), scopes: null, indent: 0, quoteKind: null, context: null, lookupVariables: true, // Is unknown variables considered an error localStates: [{ mode: modes.html, state: CodeMirror.startState(modes.html) }] }; }, copyState: function(state) { return { tag: state.tag, // Last seen Soy tag. soyState: state.soyState.concat([]), variables: state.variables, context: state.context, indent: state.indent, // Indentation of the following line. quoteKind: state.quoteKind, lookupVariables: state.lookupVariables, localStates: state.localStates.map(function(localState) { return { mode: localState.mode, state: CodeMirror.copyState(localState.mode, localState.state) }; }) }; }, token: function(stream, state) { var match; switch (last(state.soyState)) { case "comment": if (stream.match(/^.*?\*\//)) { state.soyState.pop(); } else { stream.skipToEnd(); } if (!state.context || !state.context.scope) { var paramRe = /@param\??\s+(\S+)/g; var current = stream.current(); for (var match; (match = paramRe.exec(current)); ) { state.variables = prepend(state.variables, match[1]); } } return "comment"; case "string": var match = stream.match(/^.*?(["']|\\[\s\S])/); if (!match) { stream.skipToEnd(); } else if (match[1] == state.quoteKind) { state.quoteKind = null; state.soyState.pop(); } return "string"; } if (!state.soyState.length || last(state.soyState) != "literal") { if (stream.match(/^\/\*/)) { state.soyState.push("comment"); return "comment"; } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { return "comment"; } } switch (last(state.soyState)) { case "templ-def": if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) { state.soyState.pop(); return "def"; } stream.next(); return null; case "templ-ref": if (match = stream.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/)) { state.soyState.pop(); // If the first character is '.', it can only be a local template. if (match[0][0] == '.') { return "variable-2" } // Otherwise return "variable"; } if (match = stream.match(/^\$([\w]+)/)) { state.soyState.pop(); return ref(state.variables, match[1], !state.lookupVariables); } stream.next(); return null; case "namespace-def": if (match = stream.match(/^\.?([\w\.]+)/)) { state.soyState.pop(); return "variable"; } stream.next(); return null; case "param-def": if (match = stream.match(/^\w+/)) { state.variables = prepend(state.variables, match[0]); state.soyState.pop(); state.soyState.push("param-type"); return "def"; } stream.next(); return null; case "param-ref": if (match = stream.match(/^\w+/)) { state.soyState.pop(); return "property"; } stream.next(); return null; case "open-parentheses": if (stream.match(/[)]/)) { state.soyState.pop(); return null; } return expression(stream, state); case "param-type": var peekChar = stream.peek(); if ("}]=>,".indexOf(peekChar) != -1) { state.soyState.pop(); return null; } else if (peekChar == "[") { state.soyState.push('param-type-record'); return null; } else if (peekChar == "(") { state.soyState.push('param-type-template'); return null; } else if (peekChar == "<") { state.soyState.push('param-type-parameter'); return null; } else if (match = stream.match(/^([\w]+|[?])/)) { return "type"; } stream.next(); return null; case "param-type-record": var peekChar = stream.peek(); if (peekChar == "]") { state.soyState.pop(); return null; } if (stream.match(/^\w+/)) { state.soyState.push('param-type'); return "property"; } stream.next(); return null; case "param-type-parameter": if (stream.match(/^[>]/)) { state.soyState.pop(); return null; } if (stream.match(/^[<,]/)) { state.soyState.push('param-type'); return null; } stream.next(); return null; case "param-type-template": if (stream.match(/[>]/)) { state.soyState.pop(); state.soyState.push('param-type'); return null; } if (stream.match(/^\w+/)) { state.soyState.push('param-type'); return "def"; } stream.next(); return null; case "var-def": if (match = stream.match(/^\$([\w]+)/)) { state.variables = prepend(state.variables, match[1]); state.soyState.pop(); return "def"; } stream.next(); return null; case "for-loop": if (stream.match(/\bin\b/)) { state.soyState.pop(); return "keyword"; } if (stream.peek() == "$") { state.soyState.push('var-def'); return null; } stream.next(); return null; case "record-literal": if (stream.match(/^[)]/)) { state.soyState.pop(); return null; } if (stream.match(/[(,]/)) { state.soyState.push("map-value") state.soyState.push("record-key") return null; } stream.next() return null; case "map-literal": if (stream.match(/^[)]/)) { state.soyState.pop(); return null; } if (stream.match(/[(,]/)) { state.soyState.push("map-value") state.soyState.push("map-value") return null; } stream.next() return null; case "list-literal": if (stream.match(/\]/)) { state.soyState.pop(); state.lookupVariables = true; popcontext(state); return null; } if (stream.match(/\bfor\b/)) { state.lookupVariables = true; state.soyState.push('for-loop'); return "keyword"; } return expression(stream, state); case "record-key": if (stream.match(/[\w]+/)) { return "property"; } if (stream.match(/^[:]/)) { state.soyState.pop(); return null; } stream.next(); return null; case "map-value": if (stream.peek() == ")" || stream.peek() == "," || stream.match(/^[:)]/)) { state.soyState.pop(); return null; } return expression(stream, state); case "import": if (stream.eat(";")) { state.soyState.pop(); state.indent -= 2 * config.indentUnit; return null; } if (stream.match(/\w+(?=\s+as)/)) { return "variable"; } if (match = stream.match(/\w+/)) { return /(from|as)/.test(match[0]) ? "keyword" : "def"; } if (match = stream.match(/^["']/)) { state.soyState.push("string"); state.quoteKind = match[0]; return "string"; } stream.next(); return null; case "tag": var endTag = state.tag[0] == "/"; var tagName = endTag ? state.tag.substring(1) : state.tag; var tag = tags[tagName]; if (stream.match(/^\/?}/)) { var selfClosed = stream.current() == "/}"; if (selfClosed && !endTag) { popcontext(state); } if (state.tag == "/template" || state.tag == "/deltemplate") { state.variables = prepend(null, 'ij'); state.indent = 0; } else { state.indent -= config.indentUnit * (selfClosed || indentingTags.indexOf(state.tag) == -1 ? 2 : 1); } state.soyState.pop(); return "keyword"; } else if (stream.match(/^([\w?]+)(?==)/)) { if (state.context && state.context.tag == tagName && stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) { var kind = match[1]; state.context.kind = kind; var mode = modes[kind] || modes.html; var localState = last(state.localStates); if (localState.mode.indent) { state.indent += localState.mode.indent(localState.state, "", ""); } state.localStates.push({ mode: mode, state: CodeMirror.startState(mode) }); } return "attribute"; } return expression(stream, state); case "literal": if (stream.match(/^(?=\{\/literal})/)) { state.soyState.pop(); return this.token(stream, state); } return tokenUntil(stream, state, /\{\/literal}/); } if (stream.match(/^\{literal}/)) { state.indent += config.indentUnit; state.soyState.push("literal"); state.context = new Context(state.context, "literal", state.variables); return "keyword"; // A tag-keyword must be followed by whitespace, comment or a closing tag. } else if (match = stream.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)) { var prevTag = state.tag; state.tag = match[1]; var endTag = state.tag[0] == "/"; var indentingTag = !!tags[state.tag]; var tagName = endTag ? state.tag.substring(1) : state.tag; var tag = tags[tagName]; if (state.tag != "/switch") state.indent += ((endTag || tag && tag.reduceIndent) && prevTag != "switch" ? 1 : 2) * config.indentUnit; state.soyState.push("tag"); var tagError = false; if (tag) { if (!endTag) { if (tag.soyState) state.soyState.push(tag.soyState); } // If a new tag, open a new context. if (!tag.noEndTag && (indentingTag || !endTag)) { state.context = new Context(state.context, state.tag, tag.variableScope ? state.variables : null); // Otherwise close the current context. } else if (endTag) { if (!state.context || state.context.tag != tagName) { tagError = true; } else if (state.context) { if (state.context.kind) { state.localStates.pop(); var localState = last(state.localStates); if (localState.mode.indent) { state.indent -= localState.mode.indent(localState.state, "", ""); } } popcontext(state); } } } else if (endTag) { // Assume all tags with a closing tag are defined in the config. tagError = true; } return (tagError ? "error " : "") + "keyword"; // Not a tag-keyword; it's an implicit print tag. } else if (stream.eat('{')) { state.tag = "print"; state.indent += 2 * config.indentUnit; state.soyState.push("tag"); return "keyword"; } else if (!state.context && stream.match(/\bimport\b/)) { state.soyState.push("import"); state.indent += 2 * config.indentUnit; return "keyword"; } return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); }, indent: function(state, textAfter, line) { var indent = state.indent, top = last(state.soyState); if (top == "comment") return CodeMirror.Pass; if (top == "literal") { if (/^\{\/literal}/.test(textAfter)) indent -= config.indentUnit; } else { if (/^\s*\{\/(template|deltemplate)\b/.test(textAfter)) return 0; if (/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(textAfter)) indent -= config.indentUnit; if (state.tag != "switch" && /^\{(case|default)\b/.test(textAfter)) indent -= config.indentUnit; if (/^\{\/switch\b/.test(textAfter)) indent -= config.indentUnit; } var localState = last(state.localStates); if (indent && localState.mode.indent) { indent += localState.mode.indent(localState.state, textAfter, line); } return indent; }, innerMode: function(state) { if (state.soyState.length && last(state.soyState) != "literal") return null; else return last(state.localStates); }, electricInput: /^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/, lineComment: "//", blockCommentStart: "/*", blockCommentEnd: "*/", blockCommentContinue: " * ", useInnerComments: false, fold: "indent" }; }, "htmlmixed"); CodeMirror.registerHelper("wordChars", "soy", /[\w$]/); CodeMirror.registerHelper("hintWords", "soy", Object.keys(tags).concat( ["css", "debugger"])); CodeMirror.defineMIME("text/x-soy", "soy"); });
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings