Open MogicianEik opened 4 years ago
Hi! Yes, that is something I would want to implement going forward. Users should be able to specify path for their own templates. If you want this feature with current Pyvis, you could try replacing the templates/template.html in your site-packages pyvis installation, since by default it looks for the template there.
This is already possible by using Network.set_template
and setting it to a custom template. write_html
will then load the template from this path
. The easy fix to make this more accessible would be to add path
as an optional value to the constructor of Network
I guess?
In this case write_html
, has to take an additional (optional) **kwargs
argument which then gets merged with the Jinja2 context that is already there. Otherwise, no new placeholders can be added to the custom template.
Also another thing that I noticed is that set_template
does not set the template
(jinja2.Template) but the path
to the template
This is already possible by using
Network.set_template
and setting it to a custom template.write_html
will then load the template from thispath
.
Yep! I tested by doing this
pyvis_graph = Network(height="100%", width="100%")
pyvis_graph.set_template('template.html.j2')
# Do some stuff ....
pyvis_graph.write_html('test_template.html')
webbrowser.open('test_template.html')
Hi developer team, can you allow users to specify their own HTML templates in visualization in future releases?