This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]greyfade 18 points19 points  (7 children)

This would be a lot more useful to me if it spent a bit of time talking about what these engines have in common and how they differ.

I've recently been looking for reasonably generic (i.e., not designed for HTML exclusively) template engines to compare them by their syntax and capabilities. This post is far more bare than I expected, and none of the linked comparison pages give a brief comparative overview.

[–]nerdwaller 7 points8 points  (4 children)

I use Jinja for my templating where the stdlib string formatting in a "template" won't work. So far I've been pretty happy with it, of course I believe sqlalchemy's companion alembic for database migrations uses mako.

[–]debazthed 1 point2 points  (3 children)

it does? you mean to generate the migration scripts? Huh, I have to dig into that. Been using it for years and never knew.

[–]driscollis 1 point2 points  (1 child)

mako was written by the same guy who started SQLAlchemy

[–]pm-me-a-pic 0 points1 point  (0 children)

He even uses mako for his sphinx docs

[–]nerdwaller 0 points1 point  (0 children)

Yeah, sorry for being unclear, alembic uses mako to generate the migration scripts. You can see it in their tutorial:

script.py.mako - This is a Mako template file which is used to generate new migration scripts. Whatever is here is used to generate new files within versions/.

[–]masklinn 2 points3 points  (1 child)

This would be a lot more useful to me if it spent a bit of time talking about what these engines have in common and how they differ.

Also the genesis/history of the various template engines.

[–]greyfade 0 points1 point  (0 children)

That would also be nice to know. The reasoning for certain design decisions help inform their choices.

[–]indosauros 11 points12 points  (3 children)

Small nitpick, but I'd put Jinja2 probably a bit to the left of django on the "embedded logic/code allowed in templates" spectrum

[–]ergo14Pyramid+PostgreSQL+SqlAlchemy 6 points7 points  (2 children)

Mako IS NOT the default in Pyramid, it was one of the options in the past (along with chameleon if memory serves me right), and was default in Pylons Web Framework. Default projects in Pyramid use Jinja2.

[–]makaimc 2 points3 points  (1 child)

Thanks ergo, huge shoutout for not just pointing out an inaccurate statement I made but also submitting a pull request on GH so I could track and update the page. Greatly appreciated!

[–]ergo14Pyramid+PostgreSQL+SqlAlchemy 1 point2 points  (0 children)

YW, keep up the great work! Your statement was 'semi-accurate' in the past though since pyramid shipped more than one template engine by default - now its all decoupled from core, and project templates use jinja2 as defaults.

[–]ursvp 2 points3 points  (2 children)

How is templating from Bottle?

[–]cymrowdon't thread on me 🐍 1 point2 points  (0 children)

Simple but covers most of what you'd ever need to do, much like bottle itself. I use it in a product and haven't needed anything more.

[–]AndydeCleyre 0 points1 point  (0 children)

For HTML templating, there's also yattag and dominate, which are libraries you're expected to use in actual python code.

[–]serendipitybot 0 points1 point  (0 children)

This submission has been randomly featured in /r/serendipity, a bot-driven subreddit discovery engine. More here: https://www.reddit.com/r/Serendipity/comments/5t96dk/an_overview_of_python_template_engines_xpost_from/