compone
v0.2.0 - HTML attribute helpers
COMPONE是一個Python組件框架,可以使用具有非常簡單的API的Type-Safe Python對象生成HTML,XML ,RSS和其他標記格式。
compone.Component s是任何Python Web框架或項目外的Python類,無需額外的代碼。
它是用於生成字符串的Jinja2或Django模板等模板引擎的現代替代方法。
from compone import Component , html
@ Component
def Hello ( name : str , children ):
return html . Div [
html . H1 [ f"Hello { name } !" ],
children ,
]
print ( Hello ( "World" )[ "My Child" ])
# <div><h1>Hello World!</h1>My Child</div>這是一個愚蠢的示例,但是對於更多示例和功能,請查看文檔中的教程。
您可以簡單地從PYPI安裝compone軟件包:
$ pip install compone唯一的依賴性是用於逃脫HTML的標記保護。
該文檔可在https://compone.kissgyorgy.me上找到。