babel-plugin-jsx-attrs
v1.0.0
Published
Babel plugin which transforms attributes in JSX.
Downloads
2
Readme
babel-plugin-jsx-attrs
[![Travis][travis-badge]][travis] [![npm package][npm-badge]][npm]
Transforms JSX any attributes according to specified rules .
Example
Converts
<div id="test" class="test">
<label for="test">Test</label>
</div>
(roughly) to
<div id="test" className="prefix-test">
<label htmlFor="test">Test</label>
</div>;
Installation & Usage
Install the plugin:
npm install --save-dev babel-plugin-jsx-attrs
Then edit your .babelrc
to include jsx-attrs
:
{
"plugins": [["jsx-attrs",options]]
}
options
options
must be object.
{
"for":"htmlFor" // replace attribute name only
}
{
"class":{ // replace attribute name & value
"name":"className",
"value":"prefix-{value}" // "{value}" will be replaced by the real value
}
}