{ "info": { "author": "Tom Flanagan and Jake Wharton", "author_email": "tom@zkpq.ca", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup :: HTML" ], "description": "Dominate\n========\n\n`Dominate` is a Python library for creating and manipulating HTML documents using an elegant DOM API.\nIt allows you to write HTML pages in pure Python very concisely, which eliminates the need to learn another template language, and lets you take advantage of the more powerful features of Python.\n\n\n[](https://travis-ci.org/Knio/dominate)\n[](https://coveralls.io/r/Knio/dominate?branch=master)\n\nPython:\n\n```python\nimport dominate\nfrom dominate.tags import *\n\ndoc = dominate.document(title='Dominate your HTML')\n\nwith doc.head:\n link(rel='stylesheet', href='style.css')\n script(type='text/javascript', src='script.js')\n\nwith doc:\n with div(id='header').add(ol()):\n for i in ['home', 'about', 'contact']:\n li(a(i.title(), href='/%s.html' % i))\n\n with div():\n attr(cls='body')\n p('Lorem ipsum..')\n\nprint(doc)\n```\n\nOutput:\n\n```html\n\n\n
\nLorem ipsum..
\nTest
Test
Lorem ipsum ...
\n| One | \nTwo | \nThree | \n
Have a look at our other products
\n```\n\n\nDecorators\n----------\n\n`Dominate` is great for creating reusable widgets for parts of your page. Consider this example:\n\n```python\ndef greeting(name):\n with div() as d:\n p('Hello, %s' % name)\n return d\n\nprint(greeting('Bob'))\n```\n```html\nHello, Bob
\nHello Bob
\nHello Bob
\nThis is a paragraph.
\n \n\n```\n\nEmbedding HTML\n--------------\n\nIf you need to embed a node of pre-formed HTML coming from a library such as markdown or the like, you can avoid escaped HTML by using the raw method from the dominate.util package:\n\n```\nfrom dominate.util import raw\n...\ntd(raw('Example'))\n```\n\nWithout the raw call, this code would render escaped HTML with lt, etc.\n\n\nSVG\n---\n\nThe `dominate.svg` module contains SVG tags similar to how `dominate.tags` contains HTML tags. SVG elements will automatically convert `_` to `-` for dashed elements. For example:\n\n```python\nfrom dominate.svg import *\nprint(circle(stroke_width=5))\n```\n\n```html\n