0.7.0 • Published 7 years ago

babel-plugin-moer v0.7.0

Weekly downloads
2
License
MIT
Repository
-
Last release
7 years ago

babel-plugin-moer tnpm JavaScript Style Guide

项目地址

https://coding.net/u/ncbql/p/babel-plugin-moer/git

转码例子

源代码:

import moer, { Element } from 'moer'

class Index extends Element {
  render (d) {
    const show = true
    return () => {
      d.div({ className: 'index' }); {
        d.p(); 'Hello World'
        if (show) {
          ' 0v0'
        }
      }
    }
  }
}

moer({ node: new Index() })

转码后:

import moer, { Element } from 'moer'

class Index extends Element {
  render (d) {
    const show = true
    return {
      args: { className: 'index' },
      children: [
        {
          type: 'p',
          children: [
            'Hello World',
            ...(show ? [' 0v0'] : [])
          ]
        }
      ]
    }
  }
}

moer((arg => ({ ...arg, node: arg.node.init(id) }))({ node: new Index() }))

安装模块

npm install --save-dev babel-plugin-moer

使用方法

Babel配置文件 (.babelrc)

{
  "plugins": ["moer", { "debug": true }]
}

Babel命令行 (babel-cli)

babel index.js --plugins moer 

Babel Node.js API

require('babel-core').transform('code', {
  plugins: ['moer']
})

协议

MIT

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago