-
Notifications
You must be signed in to change notification settings - Fork 303
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
static_url() is undefined in Jinja inside form.html #760
Comments
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗 |
We create our own jinja2 environment here: kubespawner/kubespawner/spawner.py Line 2943 in 6d9d9a3
I'm not sure what exactly is the best way to move forward here. |
Kubespawner renders a jinja2 template into another jinja2 template, is fix fix to ensure that static_url is parsed by the second jinja2 template rendering done by jupyterhub? |
Kubespawner renders a jinja2 template into a string, that is then passed onto JupyterHub via options_form which expects a string. That is then rendered onto a jinja2 template. I think the cleanest way perhaps is to add templating support into upstream JupyterHub for options forms, and move #724 there. |
Bug description
I am customizing jupyterhub templates by using images and css files stored in the jupyterhub static folder. When I need these images in the templates (page.html, login.html, spawner.html, etc.), I am accessing using the static_url() function with jinja. Nonetheless, I am not able to use this function or the functions url_for() and static() when calling it from inside kubespawner form.html. I also tried to access the STATIC_URL variable but the value was none.
Expected behaviour
The form.html file is used inside spawn.html in the object "{{spawner_options_form | safe}}". It is expected that some functions available by jinja when building jupyterhub templates also be available when building kubespawner form.html.
Actual behaviour
I think that Jinja is building the form html before insert this html in the spawner_options_form object of spawner.html. When building before, the function static_url() is undefined, while in the jupyterhub templates this function is defined. Below is shown the traceback when I tried to use this function in the html <img src="{{ static_url('images/cpu-ram.svg') }}>"
Your personal set up
The text was updated successfully, but these errors were encountered: