Skip to content

Commit

Permalink
feat: posthtml parser options
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Mar 16, 2023
1 parent 22c4978 commit 8e0709d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ You can run `npm run build` to compile them.
| **propsContext** | `props` | String value used as object name inside the script to process process before passed to the component. |
| **propsAttribute** | `props` | String value for props attribute to define props as JSON. |
| **propsSlot** | `props` | String value used to retrieve the props passed to slot via `$slots.slotName.props`. |
| **parserOptions** | `{recognizeSelfClosing: true}` | Object to configure `posthtml-parser`. By default, it enables support for self-closing component tags. |
| **expressions** | `{}` | Object to configure `posthtml-expressions`. You can pre-set locals or customize the delimiters for example. |
| **plugins** | `[]` | PostHTML plugins to apply for every parsed components. |
| **matcher** | `[{tag: options.tagPrefix}]` | Array of object used to match the tags. |
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = (options = {}) => tree => {
options.propsContext = options.propsContext || 'props';
options.propsAttribute = options.propsAttribute || 'props';
options.propsSlot = options.propsSlot || 'props';
options.parserOptions = options.parserOptions || {recognizeSelfClosing: true};
options.expressions = options.expressions || {};
options.plugins = options.plugins || [];
options.attrsParserRules = options.attrsParserRules || {};
Expand Down Expand Up @@ -180,7 +181,7 @@ function processTree(options) {

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

let nextNode = parser(readFileSync(componentPath, 'utf8'));
let nextNode = parser(readFileSync(componentPath, 'utf8'), options.parserOptions);

// Set filled slots
setFilledSlots(currentNode, filledSlots, options);
Expand Down

0 comments on commit 8e0709d

Please sign in to comment.