Skip to content

ChaofengYan/babel-plugin-jsx-attrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  }
}

About

Babel plugin which transforms attributes in JSX.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •