Skip to content

Commit 8e0709d

Browse files
committedMar 16, 2023
feat: posthtml parser options
1 parent 22c4978 commit 8e0709d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

‎readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ You can run `npm run build` to compile them.
116116
| **propsContext** | `props` | String value used as object name inside the script to process process before passed to the component. |
117117
| **propsAttribute** | `props` | String value for props attribute to define props as JSON. |
118118
| **propsSlot** | `props` | String value used to retrieve the props passed to slot via `$slots.slotName.props`. |
119+
| **parserOptions** | `{recognizeSelfClosing: true}` | Object to configure `posthtml-parser`. By default, it enables support for self-closing component tags. |
119120
| **expressions** | `{}` | Object to configure `posthtml-expressions`. You can pre-set locals or customize the delimiters for example. |
120121
| **plugins** | `[]` | PostHTML plugins to apply for every parsed components. |
121122
| **matcher** | `[{tag: options.tagPrefix}]` | Array of object used to match the tags. |

‎src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = (options = {}) => tree => {
5050
options.propsContext = options.propsContext || 'props';
5151
options.propsAttribute = options.propsAttribute || 'props';
5252
options.propsSlot = options.propsSlot || 'props';
53+
options.parserOptions = options.parserOptions || {recognizeSelfClosing: true};
5354
options.expressions = options.expressions || {};
5455
options.plugins = options.plugins || [];
5556
options.attrsParserRules = options.attrsParserRules || {};
@@ -180,7 +181,7 @@ function processTree(options) {
180181

181182
log(`${++processCounter}) Processing "${currentNode.tag}" from "${componentPath}"`, 'processTree');
182183

183-
let nextNode = parser(readFileSync(componentPath, 'utf8'));
184+
let nextNode = parser(readFileSync(componentPath, 'utf8'), options.parserOptions);
184185

185186
// Set filled slots
186187
setFilledSlots(currentNode, filledSlots, options);

0 commit comments

Comments
 (0)