I wrote a little utility to expand Jinja templates from the command line - https://bitbucket.org/tebeka/pythonwise/src/tip/jj2.py?at=default.
Maybe we can incorporate it to Jinja? Either as a tool or as __main__.py module?
I am torn on that. If it should come, then as a command line tool that installs through setuptools. But I am not sure on what features it should have and how to load the context etc.
IMO we can go with the minimal features that make it usable (which are the ones I currently have of course :).
What do you mean by "load the context"?
@tebeka How to load variables (the "context") into the template. In your CLI tool that would be from a JSON or YAML file.
But obviously there are more object types than the ones that can be decoded from such files. Flask has several options to load data into a config file (from_envvar, from_object, ...). I think it's a good idea to move these functions to a new package and use them in a CLI tool to load template variables.
Although the name of such a package would be a bit tricky. configutils sounds good for Flask's usecase, but it sounds absolutely ridiculous for Jinja's. OTOH dictloader would be nondescriptive, but it makes sense.
Of course creating a new package could be avoided by moving that functionality into Jinja (on which Flask depends anyway) but that seems very unelegant to me.
...or just copy the code.
@untitaker Thanks for the explanation. But please - no cut&paste :) I think your changes are orthogonal to this utility and can be done in a later stage. We can add from_envvar and friends later.
@mitsuhiko Should I submit and pull request and we'll go from there?
I agree that there should be a command-line interface to use Jinja2. The command-line should be done in a way that exposes all the features (no loss of features). Today (2015), there are more reasons than ever to have a command-line interface.