Skip to content

jsx-plus/babel-plugin-transform-jsx-condition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"]
});

About

Support of transform jsx condition directive.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •