babel-plugin-moer
v0.7.0
Published
Moer.js的语法转换插件
Downloads
2
Readme
babel-plugin-moer
项目地址
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