{"id":15442849,"url":"https://github.com/liying2008/document-template","last_synced_at":"2025-03-28T07:25:50.603Z","repository":{"id":57423421,"uuid":"126833298","full_name":"liying2008/document-template","owner":"liying2008","description":"Generate documents from templates.","archived":false,"fork":false,"pushed_at":"2023-01-07T16:42:36.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-19T09:50:55.274Z","etag":null,"topics":["document-template","pypi-packages","python","python3","template"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liying2008.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-26T13:29:55.000Z","updated_at":"2023-01-08T05:01:55.000Z","dependencies_parsed_at":"2023-02-07T16:31:09.672Z","dependency_job_id":null,"html_url":"https://github.com/liying2008/document-template","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liying2008%2Fdocument-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liying2008%2Fdocument-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liying2008%2Fdocument-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liying2008%2Fdocument-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liying2008","download_url":"https://codeload.github.com/liying2008/document-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245986685,"owners_count":20705252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["document-template","pypi-packages","python","python3","template"],"created_at":"2024-10-01T19:30:45.713Z","updated_at":"2025-03-28T07:25:50.576Z","avatar_url":"https://github.com/liying2008.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=====================\ndocument-template\n=====================\n\nPython解析文档模版\n=====================\n     \n.. image:: https://img.shields.io/pypi/v/document-template.svg\n    :target: https://pypi.org/project/document-template/\n.. image:: https://img.shields.io/pypi/pyversions/document-template.svg\n    :target: https://pypi.org/project/document-template/\n.. image:: https://img.shields.io/pypi/l/document-template.svg\n    :target: https://github.com/liying2008/document-template\n.. image:: https://img.shields.io/pypi/wheel/document-template.svg\n    :target: https://pypi.org/project/document-template/#files\n\n\n安装方法\n---------\n使用 **pip** 安装\n::\n\n    pip install document-template\n\n使用方法\n---------\n参考 test.py_  和 test.html_ :\n\n.. _test.py: https://github.com/liying2008/document-template/blob/master/test.py\n.. _test.html: https://github.com/liying2008/document-template/blob/master/test.html\n\n:test.html:\n\n.. code-block:: html\n\n    \u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"UTF-8\"\u003e\n        \u003cmeta name=\"viewport\"\n              content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\"\u003e\n        \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"\u003e\n        \u003ctitle\u003e#{title}\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n    \u003ch1\u003e#{head}\u003c/h1\u003e\n    \u003ca href=\"#{url}\"\u003e#{url}\u003c/a\u003e\n    \u003cbr\u003e\n    \u003ch1\u003e网站标题\u003c/h1\u003e\n    \u003chr\u003e\n    \u003cspan style=\"font-size: larger;font-weight: bold\"\u003e#{large_font}\u003c/span\u003e\n    \u003cbr\u003e\n    show_span 为真时显示:\n    #{bool:show_span}\u003cspan\u003eshow_span is True\u003c/span\u003e#{bool:show_span}\n    show_span 为假时显示:\n    #{bool:!show_span}\u003cspan\u003eshow_span is False\u003c/span\u003e#{bool:!show_span}\n    \u003cbr\u003e\n    #{copy:start}渲染多行文本，并替换局部内容：#{contents} 和 #{another_contents}\u003cbr\u003e\n    #{copy:end}\n    \u003c/body\u003e\n    \u003c/html\u003e\n\n:test.py:\n\n.. code-block:: python\n\n    import sys\n\n    from document_template import DocumentTemplate\n\n    __author__ = 'liying'\n\n    if sys.version_info \u003c (3, 0):\n        reload(sys)\n        sys.setdefaultencoding('utf-8')\n\n    if __name__ == '__main__':\n        id_dict = {\"title\": \"标题\", \"head\": \"正文标题\", \"url\": \"https://github.com/liying2008\", \"large_font\": \"大号字体\"}\n        id_dict['show_span'] = True\n\n        # Multi-line copy supports string, list and tuple\n        # id_dict['contents'] = 'ABCDEFG'\n        # id_dict['another_contents'] = '1234567'\n        id_dict['contents'] = ('A', 'B', 'C', 'D', 'E', 'F', 'G')\n        id_dict['another_contents'] = ['1', '2', '3', '4', '5', '6', '7']\n        dt = DocumentTemplate()\n        dt.load(\"test.html\", encoding='utf-8')\n        dt.set_identifier_dict(id_dict)\n        dt.save_document(\"new_test.html\")\n\n\n指令说明\n---------\n- **普通变量**：#{var} 定义普通模板变量；\n- **bool指令**：#{bool:var}text#{bool:var} 通过变量 var 是否为 True 控制 text 是否显示，或者 #{bool:!var}text#{bool:!var} 通过变量 var 是否为 False 控制 text 是否显示；\n- **copy指令**：#{copy:start}text#{collection_var}#{copy:end} 循环遍历 collection_var ，将其值填充到内容中。\n\n\n注意事项\n---------\n- 不支持 **copy 指令** 内使用 **copy 指令** 或 **bool 指令** 。\n\n\nLICENSE\n---------\n`MIT License \u003chttps://github.com/liying2008/document-template/blob/master/LICENSE\u003e`_\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliying2008%2Fdocument-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliying2008%2Fdocument-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliying2008%2Fdocument-template/lists"}