{ "info": { "author": "Daniil Minukhin", "author_email": "ddddsa@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Documentation", "Topic :: Utilities" ], "description": "![](https://img.shields.io/pypi/v/foliantcontrib.templateparser.svg)\n\n# TemplateParser preprocessor for Foliant\n\nPreprocessor which allows to use templates in Foliant source files. Preprocessor now supports only [Jinja2](http://jinja.pocoo.org/) templating engine, but more can be added easily.\n\n## Installation\n\n```bash\n$ pip install foliantcontrib.templateparser\n```\n\n## Config\n\nAll params that are stated in foliant.yml are considered global params. All of them may be overriden in template tag options, which have higher priority.\n\n```yaml\npreprocessors:\n - templateparser:\n engine: jinja2\n engine_params:\n root: '/usr/src/app'\n context:\n param1: 1008\n param2: 'Kittens'\n ext_context: context.yml\n param3: 'Puppies'\n```\n\n`engine`\n: name of the template engine which will be used to process template. Supported engines right now: `jinja2`.\n\n`engine_params`\n: dictionary with parameters which will be transfered to the template engine.\n\n`context`\n: dictionary with variables which will be redirected to the template.\n\n`ext_context`\n: path to YAML- or JSON-file with context dictionary. (relative to current md-file)\n\n_All parameters with other names are also transfered to the template, as if they appeared inside the `context` dictionary. (`param3` in the above example)_\n\n> Please note that even if this may seem convenient, it is preferred to include template variables in the `context` dictionary, as in future more reserved parameters may be added which may conflict with your stray variables.\n\nIf some variable names overlap among these methods to supply context, preprocessor uses this priority order:\n\n1. Context dictionary.\n2. Stray variables.\n3. External context file.\n\n## Usage\n\nTo use the template in a Markdown file just insert a tag of the template engine name, for example:\n\n```html\nThis is ordinary markdown text.\n\nThis is a Jinja2 template:\nI can count to five!\n{% for i in range(5) %}{{ i + 1 }}{% endfor %}\n\n```\n\nAfter making a document with Foliant this will be transformed to:\n\n```\nThis is ordinary markdown text.\n\nThis is a Jinja2 template:\nI can count to five!\n12345\n```\n\nYou can also use a general `