I'm writing a custom jinja2
extension to use in flask
applications and I'm looking for a way to access the templates context data using the tag I'm implementing. That is, I want the extension tag to use context params passed into the template:
@app.route('/users/<user_id>')
def user_page(user_id):
...
return render_template('users/index.html', user_id=user_id, active=True)
The template:
<!-- I want this tag to see the value of user_id and active -->
{% my_jinja2_tag %}
I know I can render the context variable using {{ user_id }}
, but what I'm looking for is a way to inspect the context of the template rendering a custom jinja2 extension. Is that doable? thanks.