docxtpl2


Namedocxtpl2 JSON
Version 0.18.1 PyPI version JSON
download
home_pagehttps://github.com/PasaOpasen/python-docx-template2
SummaryPython docx template engine (with bayoo-docx dependency)
upload_time2024-11-04 08:47:46
maintainerNone
docs_urlNone
authorEric Lapouyade
requires_pythonNone
licenseLGPL 2.1
keywords jinja2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
====================
python-docx-template
====================

Use a docx as a jinja2 template

Introduction
------------

This package uses 2 major packages :

- python-docx for reading, writing and creating sub documents
- jinja2 for managing tags inserted into the template docx

python-docx-template has been created because python-docx is powerful for creating documents but not for modifying them.

The idea is to begin to create an example of the document you want to generate with microsoft word, it can be as complex as you want :
pictures, index tables, footer, header, variables, anything you can do with word.
Then, as you are still editing the document with microsoft word, you insert jinja2-like tags directly in the document.
You save the document as a .docx file (xml format) : it will be your .docx template file.

Now you can use python-docx-template to generate as many word documents you want from this .docx template and context variables you will associate.


Documentation
-------------

Please, `read the doc <http://docxtpl.readthedocs.org>`_

Other projects
--------------

If you like python-docx-template, please have a look at some of my other projects :

- `django-listing <https://github.com/elapouya/django-listing>`_ : A listing/table library on steroid for Djano
- `python-textops3 <https://github.com/elapouya/python-textops3>`_ : Chainable text operations
- `django-robohash-svg <https://github.com/elapouya/django-robohash-svg>`_ : Create svg robots avatars



News
====
0.18.0 (2024-07-21)
-------------------
- IMPORTANT : Remove Python 2.x support
- Add hyperlink option in InlineImage (thanks to Jean Marcos da Rosa)
- Update index.rst (Thanks to jkpet)
- Add poetry env
- Black all files

0.17.0 (2024-05-01)
-------------------
- Add support to python-docx 1.1.1

0.16.8 (2024-02-23)
-------------------
- PR #527 : upgrade Jinja2 in Pipfile.lock

0.16.7 (2023-05-08)
-------------------
- PR #493 - thanks to AdrianVorobel

0.16.6 (2023-03-12)
-------------------
- PR #482 - thanks to dreizehnutters

0.16.5 (2023-01-07)
-------------------
- PR #467 - thanks to Slarag
- fix #465
- fix #464

0.16.4 (2022-08-04)
-------------------
- Regional fonts for RichText
- Reorganize documentation

0.16.3 (2022-07-14)
-------------------
- fix #448

0.16.2 (2022-07-14)
-------------------
- fix #444
- fix #443

0.16.1 (2022-06-12)
-------------------
- PR #442

0.16.0 (2022-04-16)
-------------------
- add jinja2 comment support - Thanks to staffanm

0.15.2 (2022-01-12)
-------------------
- fix #408
- Multi-rendering with same DocxTemplate object is now possible
  see tests/multi_rendering.py
- fix #392
- fix #398

0.14.1 (2021-10-01)
-------------------
- One can now use python -m docxtpl on command line
  to generate a docx from a template and a json file as a context
  Thanks to Lcrs123@github

0.12.0 (2021-08-15)
-------------------
- Code has be split into many files for better readability
- Use docxcomposer to attach parts when a docx file is given to create a subdoc
  Images, styles etc... must now be taken in account in subdocs
- Some internal XML IDs are now renumbered to avoid collision, thus images are not randomly disapearing anymore.
- fix #372
- fix #374
- fix #375
- fix #369
- fix #368
- fix #347
- fix #181
- fix #61

0.11.5 (2021-05-09)
-------------------
- PR #351
- It is now possible to put InlineImage in header/footer
- fix #323
- fix #320
- \\n, \\a, \\t and \\f are now accepted in simple context string. Thanks to chabErch@github

0.10.5 (2020-10-15)
-------------------
- Remove extension testing (#297)
- Fix spaces missing in some cases (#116, #227)

0.9.2 (2020-04-26)
-------------------
- Fix #271
- Code styling

0.8.1 (2020-04-14)
-------------------
- fix #266
- docxtpl is now able to use latest python-docx (0.8.10). Thanks to Dutchy-@github.

0.7.0 (2020-04-09)
-------------------
- Add replace_zipname() method to replace Excel and PowerPoint embedded files

0.6.4 (2020-04-06)
-------------------
- Add the possibility to add RichText to a Richtext
- Prevent lxml from attempting to parse None
- PR #207 and #209
- Handle spaces correctly when run are split by Jinja code (#205)
- PR #203
- DocxTemplate now accepts file-like objects (Thanks to edufresne)

0.5.20 (2019-05-23)
-------------------
- Fix #199
- Add support for file-like objects for replace_media (#197)
- Fix  #176
- Delegated autoescaping to Jinja2 Environment (#175)
- Force to use python-docx 0.8.7 (#170)
- Add getting undeclared variables in the template (#171)
- Added `PAGE_BREAK` feature (#168)
- Fixed issue #159: autoescaped values for both str and unicode.
- Fix tables with gridSpan that have less cells after the tc forloop (#164)
- Smart double quotes in jinja tags are now converted into simple double quotes
- Smart quotes in jinja tags are now converted into simple quotes
- Add custom jinja filter example in tests/
- Reformat the code to be a little more PEP8 compliant
- Add {% hm %} tag for table columns horizontal merging (Thanks to nickgashkov)
- Split tests/tests_files dir into templates and output dirs
- autoescape support for python 2.7
- fix issue #154
- Render can now autoescape context dict
- Fix invalid xml parse because using {% vm %}
- Cast to string non-string value given to RichText or Listing objects
- Import html.escape instead of cgi.escape (deprecated)
- Declare package as python2 and python3 compatible for wheel distrib
- Add sub/superscript in RichText
- Fix table vertical merge
- An hyperlink can now be used in RichText

0.4.13 (2018-06-21)
-------------------
- Subdocument can now be based on an existing docx
- Add font option in RichText
- Better tabs and spaces management for MS Word 2016
- Wheel distribution
- Manage autoscaping on InlineImage, Richtext and Subdoc
- Purge MANIFEST.in file
- Accept variables starting with 'r' in {{}} when no space after {{
- Remove debug traces
- Add {% vm %} to merge cell vertically within a loop (Thanks to Arthaslixin)
- use six.iteritems() instead of iteritems for python 3 compatibility
- Fixed Bug #95 on replace_pic() method
- Add replace_pic() method to replace pictures from its filename (Thanks to Riccardo Gusmeroli)
- Improve image attachment for InlineImage ojects
- Add replace_media() method (useful for header/footer images)
- Add replace_embedded() method (useful for embedding docx)

0.3.9 (2017-06-27)
------------------
- Fix exception in fix_table()
- Fix bug when using more than one {{r }} or {%r %} in the same run
- Fix git tag v0.3.6 was in fact for 0.3.5 package version
  so create a tag 0.3.7 for 0.3.7 package version
- Better head/footer jinja2 handling (Thanks to hugokernel)
- Fix bug where one is using '%' (modulo operator) inside a tag
- Add Listing class to manage \n and \a (new paragraph) and escape text AND keep current styling
- Add {%tc } tags for dynamic table columns (Thanks to majkls23)
- Remove version limitation over sphinx package in setup.py
- Add PNG & JPEG in tests/test_files/
- You can now add images directly without using subdoc, it is much more faster.

0.2.5 (2017-01-14)
------------------
- Add dynamic colspan tag for tables
- Fix /n in RichText class
- Add Python 3 support for footer and header
- Fix bug when using utf-8 chracters inside footer or header in .docx template
  It now detects header/footer encoding automatically
- Fix bug where using subdocs is corrupting header and footer in generated docx
  Thanks to Denny Weinberg for his help.
- Add Header and Footer support (Thanks to Denny Weinberg)

0.1.11 (2016-03-1)
------------------
- '>' and '<' can now be used inside jinja tags
- render() accepts optionnal jinja_env argument :
  useful to set custom filters and other things
- better subdoc management : accept tables
- better xml code cleaning around Jinja2 tags
- python 3 support
- remove debug code
- add lxml dependency
- fix template filter with quote
- add RichText support
- add subdoc support
- add some exemples in tests/
- First running version




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PasaOpasen/python-docx-template2",
    "name": "docxtpl2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "jinja2",
    "author": "Eric Lapouyade",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/bb/47/f92d9b8d26d9efb55f0977b96113eaf287d7f2bbf3ed37eac790e1d83312/docxtpl2-0.18.1.tar.gz",
    "platform": null,
    "description": "\n====================\npython-docx-template\n====================\n\nUse a docx as a jinja2 template\n\nIntroduction\n------------\n\nThis package uses 2 major packages :\n\n- python-docx for reading, writing and creating sub documents\n- jinja2 for managing tags inserted into the template docx\n\npython-docx-template has been created because python-docx is powerful for creating documents but not for modifying them.\n\nThe idea is to begin to create an example of the document you want to generate with microsoft word, it can be as complex as you want :\npictures, index tables, footer, header, variables, anything you can do with word.\nThen, as you are still editing the document with microsoft word, you insert jinja2-like tags directly in the document.\nYou save the document as a .docx file (xml format) : it will be your .docx template file.\n\nNow you can use python-docx-template to generate as many word documents you want from this .docx template and context variables you will associate.\n\n\nDocumentation\n-------------\n\nPlease, `read the doc <http://docxtpl.readthedocs.org>`_\n\nOther projects\n--------------\n\nIf you like python-docx-template, please have a look at some of my other projects :\n\n- `django-listing <https://github.com/elapouya/django-listing>`_ : A listing/table library on steroid for Djano\n- `python-textops3 <https://github.com/elapouya/python-textops3>`_ : Chainable text operations\n- `django-robohash-svg <https://github.com/elapouya/django-robohash-svg>`_ : Create svg robots avatars\n\n\n\nNews\n====\n0.18.0 (2024-07-21)\n-------------------\n- IMPORTANT : Remove Python 2.x support\n- Add hyperlink option in InlineImage (thanks to Jean Marcos da Rosa)\n- Update index.rst (Thanks to jkpet)\n- Add poetry env\n- Black all files\n\n0.17.0 (2024-05-01)\n-------------------\n- Add support to python-docx 1.1.1\n\n0.16.8 (2024-02-23)\n-------------------\n- PR #527 : upgrade Jinja2 in Pipfile.lock\n\n0.16.7 (2023-05-08)\n-------------------\n- PR #493 - thanks to AdrianVorobel\n\n0.16.6 (2023-03-12)\n-------------------\n- PR #482 - thanks to dreizehnutters\n\n0.16.5 (2023-01-07)\n-------------------\n- PR #467 - thanks to Slarag\n- fix #465\n- fix #464\n\n0.16.4 (2022-08-04)\n-------------------\n- Regional fonts for RichText\n- Reorganize documentation\n\n0.16.3 (2022-07-14)\n-------------------\n- fix #448\n\n0.16.2 (2022-07-14)\n-------------------\n- fix #444\n- fix #443\n\n0.16.1 (2022-06-12)\n-------------------\n- PR #442\n\n0.16.0 (2022-04-16)\n-------------------\n- add jinja2 comment support - Thanks to staffanm\n\n0.15.2 (2022-01-12)\n-------------------\n- fix #408\n- Multi-rendering with same DocxTemplate object is now possible\n  see tests/multi_rendering.py\n- fix #392\n- fix #398\n\n0.14.1 (2021-10-01)\n-------------------\n- One can now use python -m docxtpl on command line\n  to generate a docx from a template and a json file as a context\n  Thanks to Lcrs123@github\n\n0.12.0 (2021-08-15)\n-------------------\n- Code has be split into many files for better readability\n- Use docxcomposer to attach parts when a docx file is given to create a subdoc\n  Images, styles etc... must now be taken in account in subdocs\n- Some internal XML IDs are now renumbered to avoid collision, thus images are not randomly disapearing anymore.\n- fix #372\n- fix #374\n- fix #375\n- fix #369\n- fix #368\n- fix #347\n- fix #181\n- fix #61\n\n0.11.5 (2021-05-09)\n-------------------\n- PR #351\n- It is now possible to put InlineImage in header/footer\n- fix #323\n- fix #320\n- \\\\n, \\\\a, \\\\t and \\\\f are now accepted in simple context string. Thanks to chabErch@github\n\n0.10.5 (2020-10-15)\n-------------------\n- Remove extension testing (#297)\n- Fix spaces missing in some cases (#116, #227)\n\n0.9.2 (2020-04-26)\n-------------------\n- Fix #271\n- Code styling\n\n0.8.1 (2020-04-14)\n-------------------\n- fix #266\n- docxtpl is now able to use latest python-docx (0.8.10). Thanks to Dutchy-@github.\n\n0.7.0 (2020-04-09)\n-------------------\n- Add replace_zipname() method to replace Excel and PowerPoint embedded files\n\n0.6.4 (2020-04-06)\n-------------------\n- Add the possibility to add RichText to a Richtext\n- Prevent lxml from attempting to parse None\n- PR #207 and #209\n- Handle spaces correctly when run are split by Jinja code (#205)\n- PR #203\n- DocxTemplate now accepts file-like objects (Thanks to edufresne)\n\n0.5.20 (2019-05-23)\n-------------------\n- Fix #199\n- Add support for file-like objects for replace_media (#197)\n- Fix  #176\n- Delegated autoescaping to Jinja2 Environment (#175)\n- Force to use python-docx 0.8.7 (#170)\n- Add getting undeclared variables in the template (#171)\n- Added `PAGE_BREAK` feature (#168)\n- Fixed issue #159: autoescaped values for both str and unicode.\n- Fix tables with gridSpan that have less cells after the tc forloop (#164)\n- Smart double quotes in jinja tags are now converted into simple double quotes\n- Smart quotes in jinja tags are now converted into simple quotes\n- Add custom jinja filter example in tests/\n- Reformat the code to be a little more PEP8 compliant\n- Add {% hm %} tag for table columns horizontal merging (Thanks to nickgashkov)\n- Split tests/tests_files dir into templates and output dirs\n- autoescape support for python 2.7\n- fix issue #154\n- Render can now autoescape context dict\n- Fix invalid xml parse because using {% vm %}\n- Cast to string non-string value given to RichText or Listing objects\n- Import html.escape instead of cgi.escape (deprecated)\n- Declare package as python2 and python3 compatible for wheel distrib\n- Add sub/superscript in RichText\n- Fix table vertical merge\n- An hyperlink can now be used in RichText\n\n0.4.13 (2018-06-21)\n-------------------\n- Subdocument can now be based on an existing docx\n- Add font option in RichText\n- Better tabs and spaces management for MS Word 2016\n- Wheel distribution\n- Manage autoscaping on InlineImage, Richtext and Subdoc\n- Purge MANIFEST.in file\n- Accept variables starting with 'r' in {{}} when no space after {{\n- Remove debug traces\n- Add {% vm %} to merge cell vertically within a loop (Thanks to Arthaslixin)\n- use six.iteritems() instead of iteritems for python 3 compatibility\n- Fixed Bug #95 on replace_pic() method\n- Add replace_pic() method to replace pictures from its filename (Thanks to Riccardo Gusmeroli)\n- Improve image attachment for InlineImage ojects\n- Add replace_media() method (useful for header/footer images)\n- Add replace_embedded() method (useful for embedding docx)\n\n0.3.9 (2017-06-27)\n------------------\n- Fix exception in fix_table()\n- Fix bug when using more than one {{r }} or {%r %} in the same run\n- Fix git tag v0.3.6 was in fact for 0.3.5 package version\n  so create a tag 0.3.7 for 0.3.7 package version\n- Better head/footer jinja2 handling (Thanks to hugokernel)\n- Fix bug where one is using '%' (modulo operator) inside a tag\n- Add Listing class to manage \\n and \\a (new paragraph) and escape text AND keep current styling\n- Add {%tc } tags for dynamic table columns (Thanks to majkls23)\n- Remove version limitation over sphinx package in setup.py\n- Add PNG & JPEG in tests/test_files/\n- You can now add images directly without using subdoc, it is much more faster.\n\n0.2.5 (2017-01-14)\n------------------\n- Add dynamic colspan tag for tables\n- Fix /n in RichText class\n- Add Python 3 support for footer and header\n- Fix bug when using utf-8 chracters inside footer or header in .docx template\n  It now detects header/footer encoding automatically\n- Fix bug where using subdocs is corrupting header and footer in generated docx\n  Thanks to Denny Weinberg for his help.\n- Add Header and Footer support (Thanks to Denny Weinberg)\n\n0.1.11 (2016-03-1)\n------------------\n- '>' and '<' can now be used inside jinja tags\n- render() accepts optionnal jinja_env argument :\n  useful to set custom filters and other things\n- better subdoc management : accept tables\n- better xml code cleaning around Jinja2 tags\n- python 3 support\n- remove debug code\n- add lxml dependency\n- fix template filter with quote\n- add RichText support\n- add subdoc support\n- add some exemples in tests/\n- First running version\n\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL 2.1",
    "summary": "Python docx template engine (with bayoo-docx dependency)",
    "version": "0.18.1",
    "project_urls": {
        "Homepage": "https://github.com/PasaOpasen/python-docx-template2"
    },
    "split_keywords": [
        "jinja2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab16c3a89cfcd77275acca9d295dcff5f11dd8e706064fa1d62222c09c58bbf4",
                "md5": "4ae6a66d9db5cc6d9d17c8ad45699a79",
                "sha256": "99e698f9fb959cc87cc29b467b802b86546fc47c1d5f0a5c8eb9e4fc9f3f08af"
            },
            "downloads": -1,
            "filename": "docxtpl2-0.18.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4ae6a66d9db5cc6d9d17c8ad45699a79",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 29306,
            "upload_time": "2024-11-04T08:47:45",
            "upload_time_iso_8601": "2024-11-04T08:47:45.743402Z",
            "url": "https://files.pythonhosted.org/packages/ab/16/c3a89cfcd77275acca9d295dcff5f11dd8e706064fa1d62222c09c58bbf4/docxtpl2-0.18.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb47f92d9b8d26d9efb55f0977b96113eaf287d7f2bbf3ed37eac790e1d83312",
                "md5": "bef14159422321929e7cba92578c7824",
                "sha256": "980331c8b3fba3db6d48813f95d19f00f655fd3b5ff6aba34a8ed90d2b3e4d20"
            },
            "downloads": -1,
            "filename": "docxtpl2-0.18.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bef14159422321929e7cba92578c7824",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 31082,
            "upload_time": "2024-11-04T08:47:46",
            "upload_time_iso_8601": "2024-11-04T08:47:46.818529Z",
            "url": "https://files.pythonhosted.org/packages/bb/47/f92d9b8d26d9efb55f0977b96113eaf287d7f2bbf3ed37eac790e1d83312/docxtpl2-0.18.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-04 08:47:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PasaOpasen",
    "github_project": "python-docx-template2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "docxtpl2"
}
        
Elapsed time: 0.32543s