Skip to content

Commit 81ff51f

Browse files
authored
[soy mode] Add support for {extern and {export extern
1 parent 676b510 commit 81ff51f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

mode/soy/soy.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"@inject?": paramData,
2525
"@state": paramData,
2626
"template": { soyState: "templ-def", variableScope: true},
27+
"extern": {soyState: "param-def"},
28+
"export": {soyState: "param-def"},
2729
"literal": { },
2830
"msg": {},
2931
"fallbackmsg": { noEndTag: true, reduceIndent: true},
@@ -283,6 +285,9 @@
283285
return "type";
284286
}
285287
if (match = stream.match(/^\w+/)) {
288+
if (match[0] == 'extern') {
289+
return 'keyword';
290+
}
286291
state.variables = prepend(state.variables, match[0]);
287292
state.soyState.pop();
288293
state.soyState.push("param-type");
@@ -553,7 +558,8 @@
553558
state.context = new Context(state.context, state.tag, tag.variableScope ? state.variables : null);
554559
// Otherwise close the current context.
555560
} else if (endTag) {
556-
if (!state.context || state.context.tag != tagName) {
561+
var isBalancedForExtern = tagName == 'extern' && (state.context && state.context.tag == 'export');
562+
if (!state.context || ((state.context.tag != tagName) && !isBalancedForExtern)) {
557563
tagError = true;
558564
} else if (state.context) {
559565
if (state.context.kind) {

mode/soy/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,8 @@
311311

312312
MT('velog',
313313
'[keyword {velog] [variable-2&error $data][keyword }] Logged [keyword {/velog}]');
314+
315+
MT('extern', '[keyword {extern] [def renderer]: ([def s]:[type string])=>[type string][keyword }] [keyword {/extern}]');
316+
317+
MT('export extern', '[keyword {export] [keyword extern] [def renderer]: ([def s]:[type string])=>[type string][keyword }] [keyword {/extern}]');
314318
})();

0 commit comments

Comments
 (0)