0

What I'm looking for

I'm looking for a text templating engine (think e.g. Jinja2, Mako, or Liquid) or a higher-level library/tool making use of such an engine that supports templating on the level of whole directory trees instead of just on the level of text within a file.

All features available for templating within files (e.g. loops, conditions, etc.) should also be available for this filesystem-level templating. E.g. there should be a way to specify declaratively that you want it to template out multiple recipes according to some recipe template {{ recipe_name }}.md given a list of recipe data.

Of course this isn't that hard to do manually with existing template engines, but I run into this so often that I'd be surprised if there wasn't a ready-made system with a nice declarative syntax for it by now.

Similar existing software

cookiecutter comes close in that it does template out whole directory trees and even lets you put placeholders in filenames, e.g. you can name a file in your template directory {{ module_name }}.py and it will insert a provided module name when rendering it to disk, but AFAIK it doesn't support templating out files from loops over lists. It's also not meant to be general-purpose and has some odd conventions that stem from its intended use as a project templating tool.

1 Answer 1

1

I once again ended up writing my own which supports all the features I asked for in my question and then some:

After I got done writing it, I found out that there are similar projects already on PyPI:

I haven't tested them though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.