Skip to content

Commit 06ff5b7

Browse files
committed
Add #flush
1 parent 9295d40 commit 06ff5b7

File tree

8 files changed

+54
-3
lines changed

8 files changed

+54
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ console.log(data.tokens)
7373
- `#t`
7474
- `#nt`
7575
- `#rt`
76+
- `#flush`
7677
- comments `<#-- -->`
7778
- built-ins:
7879
- `?toUpperCase`
@@ -88,7 +89,6 @@ console.log(data.tokens)
8889
- `#escape`
8990
- `#noescape`
9091
- `#fallback`
91-
- `#flush`
9292
- `#nested`
9393
- `#recurse`
9494
- `#visit`

src/enum/NodeNames.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ enum NodeNames {
2929
Nt = 'Nt',
3030
Rt = 'Rt',
3131
T = 'T',
32+
Flush = 'Flush',
3233

3334
// Not supported
3435
// Escape = 'Escape',
3536
// NoEscape = 'NoEscape',
3637
// Visit = 'visit',
3738
// Recurse = 'Recurse',
38-
// Flush = 'Flush',
3939
// Nested = 'Nested',
4040
}
4141

src/types/Nodes/IFlush.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import NodeNames from '../../enum/NodeNames'
2+
import { IToken } from '../Tokens'
3+
import AbstractNode from './AbstractNode'
4+
5+
export default class IFlush extends AbstractNode {
6+
constructor (token : IToken) {
7+
super(NodeNames.Flush, token)
8+
}
9+
}

src/utils/Directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Directives : IDirectivesTypes = {
1717
// noescape: NodeNames.NoEscape,
1818
// fallback: NodeNames.Fallback,
1919
function: NodeNames.Function,
20-
// flush: NodeNames.Flush,
20+
flush: NodeNames.Flush,
2121
global: NodeNames.Global,
2222
import: NodeNames.Import,
2323
local: NodeNames.Local,

src/utils/Nodes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import IBreak from '../types/Nodes/IBreak'
77
import IComment from '../types/Nodes/IComment'
88
import ICompress from '../types/Nodes/ICompress'
99
import ICondition from '../types/Nodes/ICondition'
10+
import IFlush from '../types/Nodes/IFlush'
1011
import IFunction from '../types/Nodes/IFunction'
1112
import IGlobal from '../types/Nodes/IGlobal'
1213
import IImport from '../types/Nodes/IImport'
@@ -146,6 +147,9 @@ const Nodes : INodes = {
146147
[NodeNames.T] (token : IToken) : IT {
147148
return new IT(token)
148149
},
150+
[NodeNames.Flush] (token : IToken) : IFlush {
151+
return new IFlush(token)
152+
},
149153
}
150154

151155
export default Nodes

test/resource/valid/flush-ast.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"type": "Program",
3+
"start": 0,
4+
"end": 10,
5+
"body": [
6+
{
7+
"type": "Flush",
8+
"start": 0,
9+
"end": 8
10+
},
11+
{
12+
"type": "Text",
13+
"start": 8,
14+
"end": 10,
15+
"text": "\n\n"
16+
}
17+
]
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"type": "Directive",
4+
"start": 0,
5+
"end": 8,
6+
"startTag": "<#",
7+
"endTag": ">",
8+
"text": "flush",
9+
"isClose": false
10+
},
11+
{
12+
"type": "Text",
13+
"start": 8,
14+
"end": 10,
15+
"text": "\n\n",
16+
"isClose": false
17+
}
18+
]

test/resource/valid/flush.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<#flush>
2+

0 commit comments

Comments
 (0)