{ "info": { "author": "Reinhard Hainz", "author_email": "reinhard.hainz@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# haip.template\n\n[![License](https://img.shields.io/github/license/haipdev/template.svg)](LICENSE)\n[![Build Status](https://travis-ci.org/haipdev/template.svg?branch=master)](https://travis-ci.org/haipdev/template)\n\nhaip.template is Jinja2 based async template rendering module.\n\n## Features\n\n* **minimalistic**: a single exported async function \"render\"\n* **autoreturn-type**: the return data type is derived from the file suffix\n\n## Getting Started\n\n### Installing\n\n```sh\npip install haip.template\n```\n\nor from source:\n\n```sh\ngit clone https://github.com/haipdev/template.git\n```\n\n### Usage\n\n> async def render(template_filename, *, template_dir=None, **args)\n\nThe template-file is defined by *config.template_dir/template_dir/template_filename*. **args are used to fillin the placeholders in the template_file and the suffix of the template_file determines the return type. E.g. \"template_name.json\" will return a json structure (dict). *render* will propagate exceptions as they are raised by the underlaying modules.\n\nSuffix handling is as follows:\n\n* .json : json struct (dict)\n* .sql : string (but **args values will be escaped)\n* .* : string\n\n### Example\n\n#### config (using haip.config)\n\n```yaml\ntemplate-dir: /path-to-template-dir/\n```\n\nmytemplate.jinja2\n\n```jinja2\nHello my name is {{ firstname }} {{ lastname }}!\n```\n\n#### python implementation\n\n```python\nimport haip.config as config\nimport haip.template as template\n\nconfig.load('/path-to-my-config-dir')\ndocument = await template.render('mytemplate.jinja2', firstname='Reinhard', lastname='Hainz')\n```\n\nIf mytemplate.jinja is in a subdirectory of the template-dir (e.g. /path-to-template-dir/mysubdir/):\n\n```python\ndocument = await template.render('mytemplate.jinja2', template_dir='mysubdir', firstname='Reinhard', lastname='Hainz')\n```\n\nYou can also use absolute paths in the template_dir argument of the render function.\n\n## Running the tests\n\nTests are written using pytest and located in the \"tests\" directory.\n\n```sh\npytest tests\n```\n\n## Contributing\n\nFeel free to use and enhance this project. Pull requests are welcome.\n\n## Authors\n\n* **Reinhard Hainz** - *Initial work* - [haipdev](https://github.com/haipdev)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n\n## Dependencies\n\n* [haip_config](https://github.com/haipdev/config)\n* [jinja2](http://jinja.pocoo.org/)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/haipdev/template", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "haip-template", "package_url": "https://pypi.org/project/haip-template/", "platform": "", "project_url": "https://pypi.org/project/haip-template/", "project_urls": { "Homepage": "https://github.com/haipdev/template" }, "release_url": "https://pypi.org/project/haip-template/0.1.3/", "requires_dist": [ "haip-config (>=0.1.7)", "jinja2 (>=2.10)" ], "requires_python": "", "summary": "Jinja2 based template module.", "version": "0.1.3" }, "last_serial": 4883999, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "b5109e502affd4d4529216288c145cdb", "sha256": "e40cb5568dcd88f58b00b136d726a00f5369ed2173cc6f3c522d1a1209c78cdf" }, "downloads": -1, "filename": "haip_template-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b5109e502affd4d4529216288c145cdb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4018, "upload_time": "2019-03-01T12:12:12", "url": "https://files.pythonhosted.org/packages/de/fe/97c54b148b0ed8a0fec67b7c284ab74668b27142752da9a7705849c19152/haip_template-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bd42a34ec47e4067112294e7c9b15b7c", "sha256": "a89603244f5abeecff8a9ea18721884e9465a63641bb634c273fe46ad8d2c53d" }, "downloads": -1, "filename": "haip_template-0.1.2.tar.gz", "has_sig": false, "md5_digest": "bd42a34ec47e4067112294e7c9b15b7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2730, "upload_time": "2019-03-01T12:12:14", "url": "https://files.pythonhosted.org/packages/4b/a3/9c2466a3c9f4aa660934d86bddf795a6f8f90a016a698641f83c24d8c57c/haip_template-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "d0cf20a9da1337c4e751bd75f3a9b327", "sha256": "70237ac3dbeb0c3a9119ff8ff32271f50c63cf4867310f2b27388d4262dfc01b" }, "downloads": -1, "filename": "haip_template-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d0cf20a9da1337c4e751bd75f3a9b327", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4016, "upload_time": "2019-03-01T12:32:22", "url": "https://files.pythonhosted.org/packages/61/49/5f6b3dee6491f83c478a26e7985bae80921a7d45b5b0257556f27498c5cf/haip_template-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "308ed77af3647d224c9f56416f71f6ec", "sha256": "1e3e6dee0897b7158b95c20f096e68fe2ae3c7b9837c0a6046a4f129dfdc321a" }, "downloads": -1, "filename": "haip-template-0.1.3.tar.gz", "has_sig": false, "md5_digest": "308ed77af3647d224c9f56416f71f6ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2725, "upload_time": "2019-03-01T12:32:23", "url": "https://files.pythonhosted.org/packages/38/35/3be5d531fc24532ce24b403977b6bc68f5d26f9a60d1dfd64a3adea51365/haip-template-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d0cf20a9da1337c4e751bd75f3a9b327", "sha256": "70237ac3dbeb0c3a9119ff8ff32271f50c63cf4867310f2b27388d4262dfc01b" }, "downloads": -1, "filename": "haip_template-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d0cf20a9da1337c4e751bd75f3a9b327", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4016, "upload_time": "2019-03-01T12:32:22", "url": "https://files.pythonhosted.org/packages/61/49/5f6b3dee6491f83c478a26e7985bae80921a7d45b5b0257556f27498c5cf/haip_template-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "308ed77af3647d224c9f56416f71f6ec", "sha256": "1e3e6dee0897b7158b95c20f096e68fe2ae3c7b9837c0a6046a4f129dfdc321a" }, "downloads": -1, "filename": "haip-template-0.1.3.tar.gz", "has_sig": false, "md5_digest": "308ed77af3647d224c9f56416f71f6ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2725, "upload_time": "2019-03-01T12:32:23", "url": "https://files.pythonhosted.org/packages/38/35/3be5d531fc24532ce24b403977b6bc68f5d26f9a60d1dfd64a3adea51365/haip-template-0.1.3.tar.gz" } ] }