Babel plugin for e4x xml processing.
npm install\
babel-plugin-transform-simple-e4x\
babel-preset-env\
--save-dev
In your .babelrc
:
{
"presets": ["@babel/preset-env"],
"plugins": ["babel-plugin-transform-simple-e4x"]
}
The plugin transpiles the following E4X code:
const fooId = 'foo-id';
const barText = 'bar text';
let xml = (
<xml>
<foo id={fooId}>{barText}</foo>
</xml>
);
xml += <var id="var-id"/>;
To the following JavaScript:
var XML = require("simple4x");
var fooId = 'foo-id';
var barText = 'bar text';
var xml = new XML("<xml><foo id=\"" + (fooId) + "\">" + (barText) + "</foo></xml>");
xml.appendChild(new XML("<var id=\"var-id\" />"));
See tests for more examples and details.
- Babel 7 compatible
- root: Contains the README.md, the main configuration to execute the project such as package.json or any other configuration files.
- lib: Contains the source code for plugin.
- test: Contains library tests and examples.
- examples: Contains library examples.
- node_modules: Contains third party JS libraries used in this project
Download the code
git clone [email protected]:pikamachu/pika-babel-plugin-transform-simple-e4x.git
cd pika-babel-plugin-transform-simple-e4x
Install dependencies
bash pika install
Run application tests.
bash pika test