Skip to content

Commit f7a8702

Browse files
committed
feat(control flow): added control flow syntax support
1 parent 73ac62e commit f7a8702

27 files changed

Lines changed: 16847 additions & 15220 deletions

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<div align="center">
1414
<img src="assets/angular-html.png" title="vscode-angular-html" alt="Logo" />
15-
</div>
15+
</div>z
1616

1717
> Note: No theme will have the highlighting displayed in these images. For that effect, run the `vscode-angular-html: Set legacy color customizations` command from the command pallete and you're good to go.
1818
@@ -31,6 +31,7 @@ This plugin adds syntax highlighting for angular HTML template files in VS Code.
3131
- [Angular](#angular)
3232
- [Directives](#directives)
3333
- [Interpolations](#interpolations)
34+
- [Control Flow](#control-flow)
3435
- [Structural tags](#structural-tags)
3536
- [HTML](#html)
3637
- [Doctype](#doctype)
@@ -102,6 +103,10 @@ This plugin adds syntax highlighting for angular HTML template files in VS Code.
102103

103104
<img src="assets/angular-interpolations.png" title="Angular Interpolations" alt="Angular Interpolations" />
104105

106+
## Control Flow
107+
108+
<img src="assets/angular-control-flow.png" title="Angular Control Flow" alt="Angular Control Flow" />
109+
105110
## Structural tags
106111

107112
> See the [complete list](docs/ANGULAR-SPECIFIC-TAGS.md)
@@ -282,7 +287,7 @@ And with [colorize support](https://marketplace.visualstudio.com/items?itemName=
282287

283288
# Link tags
284289

285-
<img src="assets/link-tag-icon" title="Link tags" alt="Link tag" />
290+
<img src="assets/link-tag-icon.png" title="Link tags" alt="Link tag" />
286291

287292
# Theming
288293

assets/angular-control-flow.png

94.9 KB
Loading

docs/THEMING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Angular](#angular)
1414
- [Directives](#directives)
1515
- [Interpolations](#interpolations)
16+
- [Control Flow](#control-flow)
1617
- [PrimeNG](#primeng)
1718
- [HTML](#html)
1819
- [Doctype](#doctype)
@@ -110,6 +111,13 @@
110111
- `??`, `&` - html-template.ng.expression.operator.bitwise
111112
- `}}` - html-template.ng.interpolation.end
112113

114+
## Control Flow
115+
116+
<img src="../assets/angular-control-flow.png" title="Angular Control Flow" alt="Angular Control Flow" />
117+
118+
- `@` - html-template.ng.control-flow.prefix
119+
- `for`, `switch`, `if`, `[...]` - html-template.ng.control-flow.keyword
120+
113121
# PrimeNG
114122

115123
<img src="../assets/prime-ng-tags.png" title="Prime NG Tags" alt="Prime NG Tags" />

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@
283283
"type": "string",
284284
"default": "",
285285
"markdownDescription": "%ext.settings.angular.angularTemplateVariableName%"
286+
},
287+
"vscode-angular-html.controlFlowPrefix": {
288+
"type": "string",
289+
"default": "",
290+
"markdownDescription": "%ext.settings.angular.controlFlowPrefix%"
291+
},
292+
"vscode-angular-html.controlFlowKeyword": {
293+
"type": "string",
294+
"default": "",
295+
"markdownDescription": "%ext.settings.angular.controlFlowKeyword%"
286296
}
287297
}
288298
},

package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"ext.settings.angular.angularTemplateVariablePrefix": "Matches Angular template variable decorator.\n\n* &#60;div `#`menu=\"parsedMenu\"&#62;&#60;/div&#62;\n\n```html\n\n<div #menu=\"parsedMenu\"></div>\n\n\n```\nLeave it empty to disable for this item only",
3838
"ext.settings.angular.angularTemplateVariableName": "Matches Angular template variable name.\n\n* &#60;div #`menu`=\"parsedMenu\"&#62;&#60;/div&#62;\n\n```html\n\n<div #menu=\"parsedMenu\"></div>\n\n\n```\nLeave it empty to disable for this item only",
3939
"ext.settings.angular.angularExpressionOperatorsAndNavigatorsColor": "Matches Angular expressions' operators and navigators.\n\n* {{ if (key`?.`value `||` condition `&&` condition) {} }}\n\n* {{ if (key`.`value `!==` '') {} }}\n\n* {{ if (key`!.`value `===` '') {} }}\n\n```html{{\n\n{{\n\tif (key?.value || condition && condition) {}\n\tif (key.value !== '') {}\n\tif (key!.value === '') {}\n}}\n\n\n```\nLeave it empty to disable for this item only",
40+
"ext.settings.angular.controlFlowPrefix": "Matches Angular's control flow keyword prefix (@).\n\n* `@`if (showBody) { &#60;body-cmp/&#62; }\n\n* `@`else if (showSummary) { &#60;summary-cmp/&#62; }\n\n* `@`else { Nothing to see here }\n\n```html\n\n@if (showBody) {\n\t<body-cmp />\n} @else if (showSummary) {\n\t<summary-cmp />\n} @else {\n\tNothing to see here\n}\n```\nLeave it empty to disable for this item only",
41+
"ext.settings.angular.controlFlowKeyword": "Matches Angular's control flow keywords.\n\n* @`if` (showBody) { &#60;body-cmp/&#62; }\n\n* @`else if` (showSummary) { &#60;summary-cmp/&#62; }\n\n* @`else` { Nothing to see here }\n\n```html\n\n@if (showBody) {\n\t<body-cmp />\n} @else if (showSummary) {\n\t<summary-cmp />\n} @else {\n\tNothing to see here\n}\n```\nLeave it empty to disable for this item only",
4042
"ext.settings.primeng.primeNgElementTags": "Matches PrimeNG-specific element tags.\n\n* &#60;`p-calendar`&#62;&#60;/`p-calendar`&#62;\n\n* &#60;`p-button`&#62;&#60;/`p-button`&#62;\n\n```html\n\n<p-calendar></p-calendar>\n<p-button></p-button>\n\n\n```\nLeave it empty to disable for this item only",
4143
"ext.settings.svg.svgTags": "Matches known SVG elements.\n\n* &#60;`circle`&#62;&#60;/`circle`&#62;\n\n* &#60;`path`&#62;&#60;/`path`&#62;\n\n```html\n\n<circle></circle>\n<svg>\n\t<circle></circle>\n\t<path></path>\n</svg>\n\n\n```\nLeave it empty to disable for this item only",
4244
"ext.settings.svg.svgDAttributePathCommands": "Matches SVG d attribute path commands.\n\n* &#60;path d=\"`M`202.35,163.64`l`-4.38-13.1`h`-2.13`v`-3.85`h`9.1`v`3.85`h`-1.82`l`2.05,6.2`l`3.41-10.05\" /&#62;\n\n```html\n\n<svg>\n\t<path d=\"M202.35,163.64l-4.38-13.1h-2.13v-3.85h9.1v3.85h-1.82l2.05,6.2l3.41-10.05\" />\n</svg>\n\n\n```\nLeave it empty to disable for this item only",

package.nls.pt-br.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"ext.settings.angular.angularTemplateVariablePrefix": "Corresponde ao decorador de variaveis de template do Angular.\n\n* &#60;div `#`menu=\"parsedMenu\"&#62;&#60;/div&#62;\n\n```html\n\n<div #menu=\"parsedMenu\"></div>\n\n\n```\nDeixe em branco para desativar para este item.",
3838
"ext.settings.angular.angularTemplateVariableName": "Corresponde ao nome das variaveis de template do Angular.\n\n* &#60;div #`menu`=\"parsedMenu\"&#62;&#60;/div&#62;\n\n```html\n\n<div #menu=\"parsedMenu\"></div>\n\n\n```\nDeixe em branco para desativar para este item.",
3939
"ext.settings.angular.angularExpressionOperatorsAndNavigatorsColor": "Corresponde aos operadores e navegadores das expressoes Angular.\n\n* {{ if (key`?.`value `||` condition `&&` condition) {} }}\n\n* {{ if (key`.`value `!==` '') {} }}\n\n* {{ if (key`!.`value `===` '') {} }}\n\n```html{{\n\n{{\n\tif (key?.value || condition && condition) {}\n\tif (key.value !== '') {}\n\tif (key!.value === '') {}\n}}\n\n\n```\nDeixe em branco para desativar para este item.",
40+
"ext.settings.angular.controlFlowPrefix": "Corresponde ao prefixo de palavras-chave de fluxo de controle do Angular (@).\n\n* `@`if (showBody) { &#60;body-cmp/&#62; }\n\n* `@`else if (showSummary) { &#60;summary-cmp/&#62; }\n\n* `@`else { Nothing to see here }\n\n```html\n\n@if (showBody) {\n\t<body-cmp />\n} @else if (showSummary) {\n\t<summary-cmp />\n} @else {\n\tNothing to see here\n}\n```\nDeixe em branco para desativar para este item.",
41+
"ext.settings.angular.controlFlowKeyword": "Corresponde a palavras-chave de fluxo de controle do Angular.\n\n* @`if` (showBody) { &#60;body-cmp/&#62; }\n\n* @`else if` (showSummary) { &#60;summary-cmp/&#62; }\n\n* @`else` { Nothing to see here }\n\n```html\n\n@if (showBody) {\n\t<body-cmp />\n} @else if (showSummary) {\n\t<summary-cmp />\n} @else {\n\tNothing to see here\n}\n```\nDeixe em branco para desativar para este item.",
4042
"ext.settings.primeng.primeNgElementTags": "Corresponde a tags específicas do PrimeNG\n\n* &#60;`p-calendar`&#62;&#60;/`p-calendar`&#62;\n\n* &#60;`p-button`&#62;&#60;/`p-button`&#62;\n\n```html\n\n<p-calendar></p-calendar>\n<p-button></p-button>\n\n\n```\nDeixe em branco para desativar para este item.",
4143
"ext.settings.svg.svgTags": "Corresponde a elementos conhecidos do SVG.\n\n* &#60;`circle`&#62;&#60;/`circle`&#62;\n\n* &#60;`path`&#62;&#60;/`path`&#62;\n\n```html\n\n<circle></circle>\n<svg>\n\t<circle></circle>\n\t<path></path>\n</svg>\n\n\n```\nDeixe em branco para desativar para este item.",
4244
"ext.settings.svg.svgDAttributePathCommands": "Corresponde a comandos do atributo d de tags path no SVG.\n\n* &#60;path d=\"`M`202.35,163.64`l`-4.38-13.1`h`-2.13`v`-3.85`h`9.1`v`3.85`h`-1.82`l`2.05,6.2`l`3.41-10.05\" /&#62;\n\n```html\n\n<svg>\n\t<path d=\"M202.35,163.64l-4.38-13.1h-2.13v-3.85h9.1v3.85h-1.82l2.05,6.2l3.41-10.05\" />\n</svg>\n\n\n```\nDeixe em branco para desativar para este item.",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
textMateRules: [
3+
{
4+
scope: 'html-template.ng.control-flow.keyword',
5+
configRule: 'vscode-angular-html.controlFlowKeyword',
6+
},
7+
],
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
textMateRules: [
3+
{
4+
scope: 'html-template.ng.control-flow.prefix',
5+
configRule: 'vscode-angular-html.controlFlowPrefix',
6+
},
7+
],
8+
}

src/grammar/base.json5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
name: 'angular-html',
44
scopeName: 'html-template.ng',
55
patterns: [
6+
{ include: '#angular-control-flow' },
67
{ include: '#angular-interpolations' },
78
{ include: '#tag-svg' },
89
{ include: '#tag-script' },
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
repository: {
3+
'angular-control-flow': {
4+
patterns: [
5+
{
6+
include: '#control-flow-expression-parenthesis',
7+
},
8+
{
9+
include: '#control-flow-expression-no-parenthesis',
10+
},
11+
],
12+
},
13+
},
14+
}

0 commit comments

Comments
 (0)