Skip to content

Commit

Permalink
Merge pull request #161 from posthtml/types
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin authored Jul 25, 2024
2 parents b7c0cd3 + eb204d7 commit e7a09a6
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 3 deletions.
100 changes: 100 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
export type PostHTMLExpressions = {
/**
Define the starting and ending delimiters used for expressions.
@default ['{{', '}}']
*/
delimiters?: string[];

/**
Define the starting and ending delimiters used for unescaped expressions.
@default ['{{{', '}}}']
*/
unescapeDelimiters?: string[];

/**
Object containing data that will be available under the `page` object.
@default {}
*/
locals?: Record<string, unknown>;

/**
Attribute name for `<script>` tags that contain locals.
@default 'locals'
*/
localsAttr?: string;

/**
Whether to remove `<script>` tags that contain locals.
@default false
*/
removeScriptLocals?: boolean;

/**
Tag names to be used for if/else statements.
@default ['if', 'elseif', 'else']
*/
conditionalTags?: string[];

/**
Tag names to be used for switch statements.
@default ['switch', 'case', 'default']
*/
switchTags?: string[];

/**
Tag names to be used for loops.
@default ['each', 'for']
*/
loopTags?: string[];

/**
Tag names to be used for scopes.
@default ['scope']
*/
scopeTags?: string[];

/**
Name of tag inside of which expression parsing is disabled.
@default 'raw'
*/
ignoredTag?: string;

/**
Enabling strict mode will throw an error if an expression cannot be evaluated.
@default false
*/
strictMode?: boolean;

/**
What to render when referencing a value that is not defined in `locals`.
By default, the string 'undefined' will be output.
@default undefined
@example
```
// Output empty string if value is not defined
missingLocal: ''
// Output original reference if value is not defined
missingLocal: '{local}'
// Output custom string if value is not defined
missingLocal: 'ERR_NO_VALUE: {local}'
```
*/
missingLocal?: string;
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"node": ">=10"
},
"main": "lib",
"types": "lib/index.d.ts",
"files": [
"lib"
],
"scripts": {
"lint": "standard",
"test": "npm run lint && nyc ava --timeout=1m",
Expand All @@ -27,9 +31,6 @@
"standard": "^16.0.3",
"standard-changelog": "^2.0.27"
},
"files": [
"lib"
],
"keywords": [
"expressions",
"posthtml",
Expand Down

0 comments on commit e7a09a6

Please sign in to comment.