Code Monkey home page Code Monkey logo

Comments (4)

JonasCir avatar JonasCir commented on May 28, 2024 1

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.

from pyvis.

LeMoussel avatar LeMoussel commented on May 28, 2024 1

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.

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')

from pyvis.

boludo00 avatar boludo00 commented on May 28, 2024

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.

from pyvis.

JonasCir avatar JonasCir commented on May 28, 2024

Also another thing that I noticed is that set_template does not set the template (jinja2.Template) but the path to the template

from pyvis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.