Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for preserving whitespace within JSXChildren #329

Open
bterlson opened this issue Jun 16, 2024 · 1 comment
Open

Option for preserving whitespace within JSXChildren #329

bterlson opened this issue Jun 16, 2024 · 1 comment

Comments

@bterlson
Copy link

bterlson commented Jun 16, 2024

Would it be acceptable to add an option to preserve whitespace within JSXChildren? I am building a framework for generating source code with JSX and in that context whitespace is important to preserve. In particular, if I had something like:

function PythonFunction({name}) {
  return <>
    def {name}():
      <PythonFunctionBody />
  </>
}

which compiled to something like: ["\n def ", name, "():\n ", $createComponent(PythonFunctionBody, {})], then I can use the leading whitespace for the first text node to establish the baseline indent level, and book-keep subsequent indent level increases within my render function.

@ryansolid
Copy link
Owner

This seems reasonable. I'm not sure if this would impact walks at all. It should be the same and match up I imagine. But that would be my main consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants