An open API service indexing awesome lists of open source software.

https://github.com/puntorigen/easy-jsx-parser

Simple JSX tags parser that returns an easy to read object for every JSX tag
https://github.com/puntorigen/easy-jsx-parser

Last synced: 3 months ago
JSON representation

Simple JSX tags parser that returns an easy to read object for every JSX tag

Awesome Lists containing this project

README

        

# easy-jsx-parser

[![npm version](https://img.shields.io/npm/v/easy-jsx-parser)](https://www.npmjs.com/package/easy-jsx-parser) ![npm downloads](https://img.shields.io/npm/dm/easy-jsx-parser)

> Simple JSX tags parser that returns an easy to read object for every JSX tag

## Install

```
$ npm i easy-jsx-parser
```

## Usage

```js
const jsxToObj = require('easy-jsx-parser');

jsxToObj('My Child');
/*=> '{
Test: {
myProp: true,
children: 'My Child'
}
}'*/
```

## Features

* ``: Self-closing JSX tags
* ``: String props
* `` ``: Template props
* ``: True props
* ``: Boolean props
* ``: Number props
* ``: Props with arithmetic, comparison or bitwise operators
* ``: Arrays (with strings, numbers or booleans)
* ``: Objects with string keys and string, number or boolean value
* `<>Test>`: Fragments
* HTML/SVG DOM attributes are converted to correct React equivalent (`class` -> `className`)
* `console.log(data)}>`: Objects with string keys and arrow functions support
* ``: Unlimited nested JSX tags support

## License

MIT © [Pablo Schaffner](https://www.github.com/puntorigen)