Parses the attributes in a string containing a single tag.
- JavaScript 100%
| .gitignore | Ignore c8 code coverage artefacts | |
| CHANGELOG.md | Fixes #1 : if tag ends with boolean attribute, correctly set its value | |
| index.js | Fixes #1 : if tag ends with boolean attribute, correctly set its value | |
| LICENSE | Initial commit | |
| package-lock.json | Update package-lock file | |
| package.json | Fixes #1 : if tag ends with boolean attribute, correctly set its value | |
| README.md | Update readme with installation and usage instructions, etc. | |
| tests.js | Fixes #1 : if tag ends with boolean attribute, correctly set its value | |
@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 & license
Copyright © 2023-present, Aral Balkan, Small Technology Foundation. Released under AGPL version 3.0.