Update jinja2 template

Hi,
I’m trying to have my bokeh app update its template as callback of some button.
I run my app with bokeh serve
In my callback function I have the following :

curdoc().clear()
document = curdoc()
document.template = new_template_I_want_to_apply
document.add_root(some_layout)
document.add_root(some_layout2)
set_curdoc(document)

When I click on the button, what happens is that the content of the old template is not removed.
What is it I’m missing here ?

Thanks in advance,

Hi @jeupabn The template is only evaluated when the page is rendered, and the page is only rendered once, when the session is initiated. (All subsequent updates are incremental updates over a websocket, not a whole page re-render) So, I would not expect this to work. You can submit a GitHub Issue but I would expect the most likely resolution would be to make this fact clearer in the docs and/or make a second assignment raise an explicit error instead of failing silently.