跳转到主要内容

thedom 是一组 Python 对象,允许您在生成客户端的 HTML、CSS 和 JavaScript 之前在服务器端表示和交互 DOM。

项目描述

thedom

PyPI version PyPi downloads Build Status License Bitdeli Badge

thedom 是一组 Python 对象,允许开发者生成和交互服务器端的 Web 应用。它鼓励面向对象的网站开发,并通过将每个 DOM 元素分离到其自己的对象中,然后允许继承和子元素组合在一起形成标准 DOM 中未定义的新元素来实现代码重用。

编写这个

from thedom import Layout, Document, Buttons

page = Document.Document()
layout = page.addChildElement(Layout.Center()).addChildElement(Layout.Horizontal())
layout += Buttons.Button(text="Use thedom.", **{'class':'MainAction'})
layout += Buttons.Button(text="Enjoy writing less code.", **{'class':'DeleteAction'})
layout += Buttons.Button(text="100% Python.")

print page.toHTML(formatted=True)

得到这个

<!DOCTYPE html>
<html>
    <head>
    <title>
    </title>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    </meta>
    </head>
    <body>
        <div class="WCenter">
            <div class="WOuter">
                <div class="WInner">
                    <div class="WClear">
                        <input class="WBlock WLeft MainAction" type="button" value="Use thedom." />
                        <input class="WBlock WLeft DeleteAction" type="button" value="Enjoy writing less code." />
                        <input class="WBlock WLeft" type="button" value="100% Python." />
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

安装thedom

安装thedom就像这样

pip install thedom

或者如果您更喜欢

easy_install thedom

感谢并希望您觉得thedom有用!

~Timothy Crosley

项目详情


由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面