Skip to content

Commit a65d0fd

Browse files
author
Jonathan Barket
committed
Angular2 Decorator Template Highlighting
Added simple support for Angular2 inline template highlighting. In short, if we find something that looks like this: @component({ template: ` <some><html><here></here></html></some> ` }) We activate text.html.basic highlighting on the contents of the multiline string. It's possible that we could look specifically for @component, but right now, we're piggybacking off of #decorator to prevent weirdness/code duplication. To make this work, I had to remove the $base include from #decorator. If people begin passing anonymous functions and so on to decorators, this will need revisiting. But right now, we're talking about booleans and objects, so I don't know that it really needs $base. If it does, probably better to just catch @Component->template on its own.
1 parent b8d7187 commit a65d0fd

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

grammars/typescript.cson

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
'name': 'TypeScript'
99

1010
'patterns': [
11-
1211
####
1312
# Rules that no one should change
1413
# These are used by code to provide fancy completions
1514
####
16-
1715
{
1816
'comment': 'Match debugger statement'
1917
'match': '\\s*(debugger)[\\s;]+'
@@ -917,7 +915,7 @@
917915
}
918916
]
919917

920-
'functionargumentreturntype':
918+
'functionargumentreturntype':
921919
'begin': '(?=\\()'
922920
'end': '(?<!\\))(?!\\G)'
923921
'patterns': [
@@ -1047,7 +1045,7 @@
10471045
'name': 'punctuation.definition.parameters.end.js'
10481046
'patterns': [
10491047
{
1050-
'include': '$base'
1048+
'include': '#angulartemplate'
10511049
}
10521050
]
10531051

@@ -1380,5 +1378,18 @@
13801378
]
13811379

13821380
'comma':
1383-
'match': ','
1384-
'name': 'meta.delimiter.object.comma.js'
1381+
'match': ','
1382+
'name': 'meta.delimiter.object.comma.js'
1383+
1384+
'angulartemplate':
1385+
'begin': '\\b(template:\\s*`)'
1386+
'beginCaptures':
1387+
'0':
1388+
'name': 'storage.type.annotation.js'
1389+
'end': '(`)'
1390+
'endCaptures':
1391+
'0':
1392+
'name': 'storage.type.annotation.js'
1393+
'patterns': [
1394+
{ 'include': 'text.html.basic' }
1395+
]

0 commit comments

Comments
 (0)