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

[Feature Request] Extract required context variables from template string #1444

Open
alex-statsig opened this issue Jul 5, 2023 · 1 comment

Comments

@alex-statsig
Copy link

I'm building an internal tool to help teams quickly plug variables into an arbitrary nunjucks template and render it (we're using it to generate SQL queries). It would be nice if there was a way to extract the required variables (either through all codepaths are at least through the executed path of a given "render" call) so we can provide them with a list of variables to fill in. I have a rough heuristic with some regex (templateStr.matchAll(/{{\s*([a-zA-Z0-9_]+)\s*}}/g))) but it misses anything other than simple context references. I tried using a proxy object into renderString() but it seems because of the way its loaded (via first storing into a map rather than accessing as needed) this doesn't help.

@NextThread
Copy link

hey, can I work on this issue

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