Skip to content

Commit e7a09a6

Browse files
authored
Merge pull request #161 from posthtml/types
2 parents b7c0cd3 + eb204d7 commit e7a09a6

File tree

2 files changed

+104
-3
lines changed

2 files changed

+104
-3
lines changed

lib/index.d.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
export type PostHTMLExpressions = {
2+
/**
3+
Define the starting and ending delimiters used for expressions.
4+
5+
@default ['{{', '}}']
6+
*/
7+
delimiters?: string[];
8+
9+
/**
10+
Define the starting and ending delimiters used for unescaped expressions.
11+
12+
@default ['{{{', '}}}']
13+
*/
14+
unescapeDelimiters?: string[];
15+
16+
/**
17+
Object containing data that will be available under the `page` object.
18+
19+
@default {}
20+
*/
21+
locals?: Record<string, unknown>;
22+
23+
/**
24+
Attribute name for `<script>` tags that contain locals.
25+
26+
@default 'locals'
27+
*/
28+
localsAttr?: string;
29+
30+
/**
31+
Whether to remove `<script>` tags that contain locals.
32+
33+
@default false
34+
*/
35+
removeScriptLocals?: boolean;
36+
37+
/**
38+
Tag names to be used for if/else statements.
39+
40+
@default ['if', 'elseif', 'else']
41+
*/
42+
conditionalTags?: string[];
43+
44+
/**
45+
Tag names to be used for switch statements.
46+
47+
@default ['switch', 'case', 'default']
48+
*/
49+
switchTags?: string[];
50+
51+
/**
52+
Tag names to be used for loops.
53+
54+
@default ['each', 'for']
55+
*/
56+
loopTags?: string[];
57+
58+
/**
59+
Tag names to be used for scopes.
60+
61+
@default ['scope']
62+
*/
63+
scopeTags?: string[];
64+
65+
/**
66+
Name of tag inside of which expression parsing is disabled.
67+
68+
@default 'raw'
69+
*/
70+
ignoredTag?: string;
71+
72+
/**
73+
Enabling strict mode will throw an error if an expression cannot be evaluated.
74+
75+
@default false
76+
*/
77+
strictMode?: boolean;
78+
79+
/**
80+
What to render when referencing a value that is not defined in `locals`.
81+
82+
By default, the string 'undefined' will be output.
83+
84+
@default undefined
85+
86+
@example
87+
88+
```
89+
// Output empty string if value is not defined
90+
missingLocal: ''
91+
92+
// Output original reference if value is not defined
93+
missingLocal: '{local}'
94+
95+
// Output custom string if value is not defined
96+
missingLocal: 'ERR_NO_VALUE: {local}'
97+
```
98+
*/
99+
missingLocal?: string;
100+
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"node": ">=10"
77
},
88
"main": "lib",
9+
"types": "lib/index.d.ts",
10+
"files": [
11+
"lib"
12+
],
913
"scripts": {
1014
"lint": "standard",
1115
"test": "npm run lint && nyc ava --timeout=1m",
@@ -27,9 +31,6 @@
2731
"standard": "^16.0.3",
2832
"standard-changelog": "^2.0.27"
2933
},
30-
"files": [
31-
"lib"
32-
],
3334
"keywords": [
3435
"expressions",
3536
"posthtml",

0 commit comments

Comments
 (0)