You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: