一个易于使用的纯python html模板引擎
rattlep的Python项目详细描述
py是用于html的纯python模板库。 这个库没有像django或jinja这样的特殊符号。 例如:
<html><head><title>Hello, Rattle.py!</title></head><body><h1class="heading">Hello, Rattle.py!</h1></body></html>
上面的html相当于下面的python代码,其中包含cratt.py:
greeting="Hello, Rattle.py!"withhtml()ashtml:withhead():withtitle():text(greeting)withbody():withh1(className="heading"):text(greeting)# show as HTMLprint(html)
然后,您还可以自己制作可重复使用的组件:
defgreet(name):withnode("div",className="greet-wrapper")ascomponent:withnode("h1"):text(f"Hello, {name}=san")withnode("button",className="ok-btn"):text("ok!")returncomponent# and using:withgreet("User"):pass
享受吧!