Skip to content

Add a nested option to get_undeclared_template_variables - #669

Open
cvas22 wants to merge 1 commit into
elapouya:masterfrom
cvas22:feat/538-nested-undeclared-variables
Open

cvas22 wants to merge 1 commit into
elapouya:masterfrom
cvas22:feat/538-nested-undeclared-variables

Conversation

@cvas22

@cvas22 cvas22 commented Nov 8, 2026

Copy link
Copy Markdown

Fixes #538.

get_undeclared_template_variables() only returns the top level name, so {{ foo.bar }} gives foo. I added a nested=True option that returns the dotted paths instead: foo.bar, and foo.baz for {{ foo['baz'] }}. The default stays the same, so nothing changes for existing callers, and the context filter works with both.

Notes

Only attribute and string-key lookups are followed. Something like items[0] still gives items, since there's no sensible path for an index.

I added tests/get_undeclared_variables_nested.py, which builds its own template and runs fine with the existing get_undeclared_variables.py test.

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
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

Successfully merging this pull request may close these issues.

Need support for nested data in get_undeclared_template_variables method

1 participant