@small-tech/attribute-parser

1.0.2 • Public • Published

@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.

/@small-tech/attribute-parser/

    Package Sidebar

    Install

    npm i @small-tech/attribute-parser

    Weekly Downloads

    2

    Version

    1.0.2

    License

    AGPL-3.0-or-later

    Unpacked Size

    44 kB

    Total Files

    6

    Last publish

    Collaborators

    • aral