Skip to content

Commit

Permalink
[soy mode] Add support for {extern and {export extern
Browse files Browse the repository at this point in the history
  • Loading branch information
iteriani committed Jun 18, 2021
1 parent 676b510 commit 81ff51f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mode/soy/soy.js
Expand Up @@ -24,6 +24,8 @@
"@inject?": paramData,
"@state": paramData,
"template": { soyState: "templ-def", variableScope: true},
"extern": {soyState: "param-def"},
"export": {soyState: "param-def"},
"literal": { },
"msg": {},
"fallbackmsg": { noEndTag: true, reduceIndent: true},
Expand Down Expand Up @@ -283,6 +285,9 @@
return "type";
}
if (match = stream.match(/^\w+/)) {
if (match[0] == 'extern') {
return 'keyword';
}
state.variables = prepend(state.variables, match[0]);
state.soyState.pop();
state.soyState.push("param-type");
Expand Down Expand Up @@ -553,7 +558,8 @@
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) {
var isBalancedForExtern = tagName == 'extern' && (state.context && state.context.tag == 'export');
if (!state.context || ((state.context.tag != tagName) && !isBalancedForExtern)) {
tagError = true;
} else if (state.context) {
if (state.context.kind) {
Expand Down
4 changes: 4 additions & 0 deletions mode/soy/test.js
Expand Up @@ -311,4 +311,8 @@

MT('velog',
'[keyword {velog] [variable-2&error $data][keyword }] Logged [keyword {/velog}]');

MT('extern', '[keyword {extern] [def renderer]: ([def s]:[type string])=>[type string][keyword }] [keyword {/extern}]');

MT('export extern', '[keyword {export] [keyword extern] [def renderer]: ([def s]:[type string])=>[type string][keyword }] [keyword {/extern}]');
})();

0 comments on commit 81ff51f

Please sign in to comment.