1.0.18 • Published 3 years ago

jxml-react v1.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

🚀 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>
);
1.0.18

3 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago