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

Report reads of undefined Jinja variables #253

Open
Chealer opened this issue Jun 29, 2020 · 0 comments
Open

Report reads of undefined Jinja variables #253

Chealer opened this issue Jun 29, 2020 · 0 comments

Comments

@Chealer
Copy link

Chealer commented Jun 29, 2020

In CKAN 2.8.4, reading a Jinja variable which was not defined results in reading an empty string. Looping over an undefined variable will therefore quietly ignore the loop. This happens even in debug mode.

To facilitate development, such reads should be reported somehow. Jinja's StrictUndefined allows to cause a crash when reading an undefined variable, but that may be excessive even in debug mode. What I would recommend would be to define some handler which would add something to the "Debug x" section at the bottom of pages, probably in a new "Jinja warnings" subsection if there is none. Or perhaps to add a part in the paragraph of each template which generates warnings.

Jinja's make_logging_undefined() seems to allow creating such handlers. I had trouble understand its description, but the example in this message suggests it's not difficult.

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

1 participant