jxml-react

1.0.18 • Public • Published

🚀 JXML: Render components from Yaml file.

JXML turns yaml file into JSX components.

Install:

npm i jxml-react

Add webpack config:

module.exports = {
  module: {
    // ...

    rules: [
      // ...

      {
        test: /\.jxml?$/,
        use: ['babel-loader', 'jxml-react/loader'],
      },
    ],
  },
};

Example:

Create a yaml file with extension ./example.jxml

---
version: 1.0

state:
  pageTitle: Page title

props:
  title: Default Button

render:
  H1: this.state.pageTitle
  Button:
    style:
      background: blue
      color: white
      padding: 10px
    children: this.props.title
    onClick: !!js |
      () => {
        this.setState(state=> {
            state.pageTitle = 'Hello World!'
        })
      }

and then you can import this component to jsx file:

import Example from './Example.jxml';

export default () => <Example />;

Runtime Render:

import { JXProvider } from 'jxml-react';

export default () => (
  <JXProvider context={{ components: {}, scope: {}, thisContext: {} }}>
    {`
---
version: 1.0 
render: 
  Button: Default Button
`}
  </JXProvider>
);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.180latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.180
1.0.170
1.0.160
1.0.150
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i jxml-react

Weekly Downloads

0

Version

1.0.18

License

MIT

Unpacked Size

3.15 MB

Total Files

33

Last publish

Collaborators

  • etamity