babel-plugin-transform-jsx-condition

0.1.3 • Public • Published

babel-plugin-transform-jsx-condition

Support of transform jsx condition directive.

Example

In

// input code
<View x-if={condition}>First</View>
<View x-elseif={another}>Second</View>
<View x-else>Third</View>

Out

{
  createCondition([
    [
      () => condition,
      () => <View}>First</View>
    ],
    [
      () => another,
      () => <View}>Second</View>
    ],
    [
      () => true,
      () => <View}>Third</View>
    ],
  ])
}

Installation

$ npm install babel-plugin-transform-jsx-condition

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-jsx-condition"]
}

Via CLI

$ babel --plugins transform-jsx-condition script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-jsx-condition"]
});

Package Sidebar

Install

npm i babel-plugin-transform-jsx-condition

Weekly Downloads

532

Version

0.1.3

License

none

Unpacked Size

8.7 kB

Total Files

12

Last publish

Collaborators

  • zeroling