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

Is there an possibility to generate real code instead of a list of strings? #2

Open
the-man-with-a-golden-mind opened this issue Dec 23, 2023 · 1 comment

Comments

@the-man-with-a-golden-mind

Hello there,
Is there such possibility?
I am getting string[] as a code. I can try solve it with .join("") and 'eval' but it is not a safe way.

My server is returning me md as a view (from Notion).

Best,

MM

@Tao-VanJS
Copy link
Member

We intentionally chose to return string[] for code lines instead of having all the code in a single string to allow users to apply appropriate indentation after code generation. This technique is used for generating VanJS code from .md files for the https://vanjs.org/ website. See this example: https://github.com/vanjs-org/vanjs-org.github.io/blob/62453bea1f8dd91e1f9bb2720c5b44086dd16505/codegen/gen-code.ts#L21.

Calling .join("") is a small price to pay in exchange for the flexibility on indentation. I don't think eval is ever needed for the use case of the converter.

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