Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
.. image:: https://img.shields.io/pypi/v/document-template.svg :target: https://pypi.org/project/document-template/ .. image:: https://img.shields.io/pypi/pyversions/document-template.svg :target: https://pypi.org/project/document-template/ .. image:: https://img.shields.io/pypi/l/document-template.svg :target: https://github.com/liying2008/document-template .. image:: https://img.shields.io/pypi/wheel/document-template.svg :target: https://pypi.org/project/document-template/#files
使用 pip 安装 ::
pip install document-template
参考 test.py_ 和 test.html_ :
.. _test.py: https://github.com/liying2008/document-template/blob/master/test.py .. _test.html: https://github.com/liying2008/document-template/blob/master/test.html
:test.html:
.. code-block:: html
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>#{title}</title>
</head>
<body>
<h1>#{head}</h1>
<a href="#{url}">#{url}</a>
<br>
<h1>网站标题</h1>
<hr>
<span style="font-size: larger;font-weight: bold">#{large_font}</span>
<br>
show_span 为真时显示:
#{bool:show_span}<span>show_span is True</span>#{bool:show_span}
show_span 为假时显示:
#{bool:!show_span}<span>show_span is False</span>#{bool:!show_span}
<br>
#{copy:start}渲染多行文本,并替换局部内容:#{contents} 和 #{another_contents}<br>
#{copy:end}
</body>
</html>
:test.py:
.. code-block:: python
import sys
from document_template import DocumentTemplate
__author__ = 'liying'
if sys.version_info < (3, 0):
reload(sys)
sys.setdefaultencoding('utf-8')
if __name__ == '__main__':
id_dict = {"title": "标题", "head": "正文标题", "url": "https://github.com/liying2008", "large_font": "大号字体"}
id_dict['show_span'] = True
# Multi-line copy supports string, list and tuple
# id_dict['contents'] = 'ABCDEFG'
# id_dict['another_contents'] = '1234567'
id_dict['contents'] = ('A', 'B', 'C', 'D', 'E', 'F', 'G')
id_dict['another_contents'] = ['1', '2', '3', '4', '5', '6', '7']
dt = DocumentTemplate()
dt.load("test.html", encoding='utf-8')
dt.set_identifier_dict(id_dict)
dt.save_document("new_test.html")
MIT License <https://github.com/liying2008/document-template/blob/master/LICENSE>
_
FAQs
Generate documents from templates.
We found that document-template demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.