Documents is a simple template engine built on top of Jinja2 and built with Click. It turns your templates into interactive cli applications and returns a rendered document ready to be saved.
- Clone the repository
- Run python setup.py install
You can use Documents as a cli appliaction or as a module.
Simply run documents from you command line. For additional information run documents --help.
--temp_dir The path to the template directory. Default is ./templates --extensions Limit the template files by listing extensions --template The name of the templat)
If you want to integrate Documents into your app or you simpy want to play with the module, just import documents.
Example:
>>> from documents import get_env, get_templates >>> get_templates(get_env()) # Returns a list of templates in the templates dir
What the app does is it looks into your templates directory - the default directory is ./templates - and returns the list of your templates.
Templates can be HTML, md, rst or any text files you wish, regardless of their markup. What makes them templates is the use of the Jinja2 markup language. The basic idea is that variables are encapsulated with curly brackets {{ }}.
There is of course a lot more to it, and tons of options, like template inheritance, so I encourage you to read Jinja2's documentation.
When the app get's a template it looks for its variables and turns them into "prompts" (click.prompt() methods to be exact). Once the user enters all the variables, the app crates a dict and renders the template with it.
For now the app has no save option. But one will be added soon. Till then I recomend using a pipe.
I'll be doing a Flask app and a Flask Rest API with a simple JS frontend in the future, so you won't be stuck with the cli version.
If you have any suggestions or just feel like talking, find me on Twtitter: @dasdachs_.
Cheers!