Jupyter notebook show template


is there a way to use templates when showing documents in a Jupyter Notebook?
Currently I am using directory format for my “standalone” bokeh app but I would like to also use that template for my notebook version.

Thanks in advance

I have not personally tried it but you should be able to set doc.template in the function handler for the app.

Thanks for the quick reply.
I tried the following (setting the template by path and by loading a jinja2.Template directly but to no avail.
I do not get any feedback (nor does the template show up) even if I put some garbage into doc.template, I just get the standard plot.
Any ideas?

from bokeh.io import show
from bokeh.plotting import figure
import jinja2

def show_stuff():
    def mod_doc(doc):
        fig = figure(width=500, height=500)
        doc.template = "path/to/my/template/index.html"

        #templateLoader = jinja2.FileSystemLoader(searchpath="path/to/my/template")
        #templateEnv = jinja2.Environment(loader=templateLoader)
        #TEMPLATE_FILE = "index.html"
        #template = templateEnv.get_template(TEMPLATE_FILE)
        #doc.template = template

AFAIK it expects an actual Template object, not a path, so I would try making that change first.

I tried that already (that’s the commented out portion of the code above).

Sadly does not work either.

Might require new work on the jupyter_bokeh extension. At this point I can only suggest filing a GitHub Issue.

I understand, thanks; I might create a FeatureRequest soon™.

Can you maybe suggest a way of embedding local js/css files into a jupyter notebook from within my bokehapp (much like bokeh’s output_notebook), as a bandaid?

I’m not sure offhand, I am not much of a notebook user. cc @Philipp_Rudiger @mateusz in case they have any ideas.


@Philipp_Rudiger , @mateusz do you have any ideas how to load local js+css files into Jupyter Notebook from within the bokeh-app?