Skip to content

Render to and from AST #88

@yandeu

Description

@yandeu

Would be nice to convert Nano JSX to and from an AST.

const App = () => {
  return (
    <div>
      <h1 style="color: blue;">title</h1>
      <p>paragraph</p>
    </div>
  )
}

const tree = renderToTree(<App />)

// tree would be something like this:
{
  type: 'FC',
  name: 'App',
  children: [
    {
      type: 'html',
      name: 'div',
      children: [
        { type: 'html', name: 'h1', body: 'title', props: { style: 'color: blue;' } },
        { type: 'html', name: 'p', body: 'paragraph' }
      ]
    }
  ]
}

// modify the tree if needed and render it to html
const html = renderFromTree(tree)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions