1
0
Fork
You've already forked attribute-parser
0
Parses the attributes in a string containing a single tag.
  • JavaScript 100%
2023年06月02日 15:07:27 +01:00
.gitignore Ignore c8 code coverage artefacts 2023年06月01日 15:53:18 +01:00
CHANGELOG.md Fixes #1 : if tag ends with boolean attribute, correctly set its value 2023年06月02日 15:07:27 +01:00
index.js Fixes #1 : if tag ends with boolean attribute, correctly set its value 2023年06月02日 15:07:27 +01:00
LICENSE Initial commit 2023年05月31日 16:23:33 +00:00
package-lock.json Update package-lock file 2023年06月01日 15:55:43 +01:00
package.json Fixes #1 : if tag ends with boolean attribute, correctly set its value 2023年06月02日 15:07:27 +01:00
README.md Update readme with installation and usage instructions, etc. 2023年06月01日 16:22:41 +01:00
tests.js Fixes #1 : if tag ends with boolean attribute, correctly set its value 2023年06月02日 15:07:27 +01:00

@small-tech/attribute-parser

Parses the attributes in a string containing a single tag.

Install

npm install @small-tech/attribute-parser

Use

import parseAttributes from '@small-tech/attribute-parser'
const tag = `
 <tag
 booleanAttribute
 unquotedAttribute=value1
 singleQuotesAttribute='value2'
 doubleQuotedAttribute="value3"
 attribute-with-dashes='value4'
 >...</tag>
`
parseAttributes (tag)

Returns:

{
 booleanAttribute: true,
 unquotedAttribute: 'value1',
 singleQuotedAttribute: 'value2',
 doubleQuotedAttribute: 'value3',
 attributeWithDashes: 'value4'
}

Like this? Fund us!

Small Technology Foundation is a tiny, independent not-for-profit.

We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.

Copyright © 2023-present, Aral Balkan, Small Technology Foundation. Released under AGPL version 3.0.