Skip to content
Snippets Groups Projects
Commit f47006e2 authored by Oskar Segersvärd's avatar Oskar Segersvärd
Browse files

[soy mode] Support single-quoted strings in tags

parent e47753cf
No related branches found
No related tags found
No related merge requests found
......@@ -90,6 +90,7 @@
variables: null,
scopes: null,
indent: 0,
quoteKind: null,
localStates: [{
mode: modes.html,
state: CodeMirror.startState(modes.html)
......@@ -107,6 +108,7 @@
variables: state.variables,
scopes: state.scopes,
indent: state.indent, // Indentation of the following line.
quoteKind: state.quoteKind,
localStates: state.localStates.map(function(localState) {
return {
mode: localState.mode,
......@@ -211,8 +213,9 @@
});
}
return "attribute";
} else if (stream.match(/^"/)) {
} else if (match = stream.match(/^["']/)) {
state.soyState.push("string");
state.quoteKind = match;
return "string";
}
if (match = stream.match(/^\$([\w]+)/)) {
......@@ -233,10 +236,11 @@
return tokenUntil(stream, state, /\{\/literal}/);
case "string":
var match = stream.match(/^.*?("|\\[\s\S])/);
var match = stream.match(/^.*?(["']|\\[\s\S])/);
if (!match) {
stream.skipToEnd();
} else if (match[1] == "\"") {
} else if (match[1] == state.quoteKind) {
state.quoteKind = null;
state.soyState.pop();
}
return "string";
......
......@@ -101,4 +101,8 @@
' [keyword {/if}]',
'[keyword {/template}]',
'');
MT('single-quote-strings',
'[keyword {][string "foo"] [string \'bar\'][keyword }]',
'');
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment