Skip to content

Commit d4adb09

Browse files
authored
Add tests and fix leaking braces (#25)
* add tests * add header * add more cases * do not leak braces into html context * test basics * bump action * fail it * add more
1 parent 6c14550 commit d4adb09

File tree

3 files changed

+175
-22
lines changed

3 files changed

+175
-22
lines changed

.github/workflows/test.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Syntax Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
st4_syntax_tests:
7+
name: Run ST4 Syntax Tests
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- uses: SublimeText/syntax-test-action@v2
13+
with:
14+
build: 4152
15+
default_packages: v4152
16+
package_name: Ngx HTML

NgxHTML.sublime-syntax

+23-22
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,27 @@ contexts:
9393
scope: keyword.control.control-flow.html
9494
captures:
9595
1: punctuation.definition.keyword.html
96-
- match: \(
97-
scope: punctuation.section.group.begin.html
9896
push:
99-
- meta_scope: meta.group.html
100-
- match: \b(async)\b
101-
scope: keyword.control.html
102-
- match: \b(track|of|prefetch on|on|prefetch when|when|as)\b
103-
scope: keyword.operator.word.html
104-
- match: \b(minimum|after)\b(\?)
105-
captures:
106-
1: keyword.operator.word.html
107-
2: keyword.control.question.html
108-
- match: \)
109-
scope: punctuation.section.group.end.html
110-
pop: 1
111-
- match: \{
112-
scope: punctuation.section.block.begin.html
113-
push:
114-
- meta_scope: meta.block.html
115-
- include: main
116-
- match: \}
117-
scope: punctuation.section.block.end.html
118-
pop: 1
97+
- match: \{
98+
scope: punctuation.section.block.begin.html
99+
push:
100+
- meta_scope: meta.block.html
101+
- include: main
102+
- match: \}
103+
scope: punctuation.section.block.end.html
104+
pop: 2
105+
- match: \(
106+
scope: punctuation.section.group.begin.html
107+
push:
108+
- meta_scope: meta.group.html
109+
- match: \b(async)\b
110+
scope: keyword.control.html
111+
- match: \b(track|of|prefetch on|on|prefetch when|when|as)\b
112+
scope: keyword.operator.word.html
113+
- match: \b(minimum|after)\b(\?)
114+
captures:
115+
1: keyword.operator.word.html
116+
2: keyword.control.question.html
117+
- match: \)
118+
scope: punctuation.section.group.end.html
119+
pop: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<!-- SYNTAX TEST "NgxHTML.sublime-syntax" -->
2+
3+
@if (loggedIn) {
4+
<!-- <- punctuation.definition.keyword.html -->
5+
<!-- <- keyword.control.control-flow.html -->
6+
<!-- <- keyword.control.control-flow.html -->
7+
<!-- ^ punctuation.section.block.begin.html -->
8+
The user is logged in
9+
} @else {
10+
<!-- <- punctuation.section.block.end.html -->
11+
<!-- ^ punctuation.section.block.begin.html -->
12+
<!-- <- punctuation.definition.keyword.html -->
13+
<!-- <- keyword.control.control-flow.html -->
14+
<!-- <- keyword.control.control-flow.html -->
15+
<!-- <- keyword.control.control-flow.html -->
16+
<!-- <- keyword.control.control-flow.html -->
17+
The user is not logged in
18+
}
19+
<!-- <- punctuation.section.block.end.html -->
20+
21+
@if (a > b) {
22+
{{ a }} is greater than {{ b }}
23+
<!-- <- punctuation.section.interpolation.begin.ngx.html -->
24+
<!-- <- punctuation.section.interpolation.begin.ngx.html -->
25+
<!-- <- punctuation.section.interpolation.end.ngx.html -->
26+
<!-- <- punctuation.section.interpolation.end.ngx.html -->
27+
}
28+
29+
@if (a > b) {
30+
{{ a }} is greater than {{ b }}
31+
} @else if (b > a) {
32+
{{ a }} is less than {{ b }}
33+
} @else {
34+
{{ a }} is equal to {{ b }}
35+
}
36+
37+
@switch (accessLevel) {
38+
@case ('admin') {
39+
<admin-dashboard />
40+
<!-- ^^^^^^^^^^^^^^^ entity.name.tag.other.html -->
41+
<!-- <- punctuation.definition.tag.begin.html -->
42+
<!-- <- punctuation.definition.tag.end.html -->
43+
<!-- <- punctuation.definition.tag.end.html -->
44+
}
45+
@case ('moderator') {
46+
<moderator-dashboard />
47+
}
48+
@default {
49+
<user-dashboard />
50+
}
51+
}
52+
53+
@for (user of users; track user.id) {
54+
{{ user.name }}
55+
} @empty {
56+
Empty list of users
57+
}
58+
59+
@defer {
60+
<comment-list />
61+
}
62+
63+
@defer (on viewport) {
64+
<comment-list />
65+
} @placeholder {
66+
<!-- A placeholder content to show until the comments load -->
67+
<img src="comments-placeholder.png" />
68+
}
69+
70+
@defer (on viewport) {
71+
<comment-list />
72+
} @loading {
73+
Loading…
74+
} @error {
75+
Loading failed :(
76+
} @placeholder {
77+
<img src="comments-placeholder.png" />
78+
}
79+
80+
@defer (on viewport; prefetch on idle) {
81+
<comment-list />
82+
}
83+
84+
@for (item of items; track item.id; let idx = $index, e = $even) {
85+
Item #{{ idx }}: {{ item.name }}
86+
}
87+
88+
@for (item of items) {
89+
<a [href]="item.link">{{ item.title }}</a>
90+
}
91+
92+
@for (item of items) {
93+
<a [href]="item.link">{{ item.title }}</a>
94+
} @empty {
95+
<p>No Items</p>
96+
}
97+
98+
@for (item of items; track item.name) {
99+
<li>{{ item.name }}</li>
100+
} @empty {
101+
<li>There are no items.</li>
102+
}
103+
104+
@if (users$ | async; as users) {
105+
{{ users.length }}
106+
}
107+
108+
@for (item of items; track item.id) {
109+
{{ item.name }}
110+
}
111+
112+
@switch (condition) {
113+
@case (caseA) {
114+
Case A.
115+
}
116+
@case (caseB) {
117+
Case B.
118+
}
119+
@default {
120+
Default case.
121+
}
122+
}
123+
124+
@defer (on <trigger>; when <condition>; prefetch on <trigger>; prefetch when <condition>) {
125+
<!-- deferred template fragment -->
126+
<calendar-cmp />
127+
} @placeholder (minimum? <duration>) {
128+
<!-- placeholder template fragment -->
129+
<p>Placeholder</p>
130+
} @loading (minimum? <duration>; after? <duration>) {
131+
<!-- loading template fragment -->
132+
<img alt="loading image" src="loading.gif" />
133+
} @error {
134+
<!-- error template fragment -->
135+
<p>An loading error occured</p>
136+
}

0 commit comments

Comments
 (0)