I'd like to fill a HTML template with data from Python. While I don't know any HTML, a colleague of mine would prepare the HTML template whereas I provide the data. However, he knows only little about Python.
Could you suggest a very basic template framework which handles this separation of HTML and Python nicely (i.e. not much special syntax in HTML; and not much HTML for me to know in the Python data code)? Ideally the HTML template should be very close to pure HTML.
I will also have tables as data, so it would be nice if I didn't have to prepare HTML table code, but instead he could do it with some minimal markup logic. Ideally the system should work even if my colleague applies more advanced concepts like CSS.
I've found the extensive list, but it's really hard to judge which of the system is closest to my requirements as I don't know the technical language.
EDIT: the point is we are newbies with that, and we only need a basic solution :) - yet ideally no HTML for me and not much beyond plain HTML for him.
Python String Template: The Python string Template is created by passing the template string to its constructor. It supports $-based substitutions. This class has 2 key methods: substitute(mapping, **kwds): This method performs substitutions using a dictionary with a process similar to key-based mapping objects.
If you're interested in web development with Python, then knowing HTML and CSS will help you understand web frameworks like Django and Flask better. But even if you're just getting started with Python, HTML and CSS can enable you to create small websites to impress your friends.
Jinja is a web template engine for the Python programming language. It was created by Armin Ronacher and is licensed under a BSD License. Jinja is similar to the Django template engine but provides Python-like expressions while ensuring that the templates are evaluated in a sandbox.
Well django has very nice powerful templating engine, that's purpose is separating HTML from python logic (but that would require you to use django altogether, so it might be an overkill if you just want templating).
If your templates are really easy (no loops) you might use native python string.format function (I used it in a side project that generated config files to some Fortran code, and it wasn't so bad).
Other choice might be jinja2 that is really close to django templates, but standalone and more powerful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With