Accessing Local Context in a Function? #1796
Unanswered
abirmingham
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I'm writing a
gettext
wrapper for various reasons. My wrapper function is defined on the template globals like so:The jinja template looks like this:
In
my_gettext
, I can accesssome_global_var
viacontext
, but I have no way of accessing the local variablex
. I could do this:...and then access
x
viakwargs
, but I would prefer not to, as in a real template this would introduce a lot of redundancy (especially if global variable access is also done this way).My goal is to continue to implement the
gettext
API so that I can use tools like extraction, but I want template authors to be able to refer to variables without passing them in, as this adds verbosity and an opportunity for template author error. Are there any good solutions here?Thank you!
Beta Was this translation helpful? Give feedback.
All reactions