dominate


Namedominate JSON
Version 2.9.0 PyPI version JSON
download
home_page
SummaryDominate is a Python library for creating and manipulating HTML documents using an elegant DOM API.
upload_time2023-11-16 05:47:28
maintainer
docs_urlNone
authorJake Wharton
requires_python>=3.4
licenseLGPL-3.0-or-newer
keywords framework templating template html xhtml python html5
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Dominate
========

`Dominate` is a Python library for creating and manipulating HTML documents using an elegant DOM API.
It 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.

![Python version](https://img.shields.io/pypi/pyversions/dominate.svg?style=flat)
[![Build status](https://github.com/Knio/dominate/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Knio/dominate/actions/workflows/ci.yml?query=branch%3Amaster+)
[![Coverage status](https://img.shields.io/coveralls/github/Knio/dominate/master.svg?style=flat)](https://coveralls.io/r/Knio/dominate?branch=master)

Python:

```python
import dominate
from dominate.tags import *

doc = dominate.document(title='Dominate your HTML')

with doc.head:
    link(rel='stylesheet', href='style.css')
    script(type='text/javascript', src='script.js')

with doc:
    with div(id='header').add(ol()):
        for i in ['home', 'about', 'contact']:
            li(a(i.title(), href='/%s.html' % i))

    with div():
        attr(cls='body')
        p('Lorem ipsum..')

print(doc)
```

Output:

```html
<!DOCTYPE html>
<html>
  <head>
    <title>Dominate your HTML</title>
    <link href="style.css" rel="stylesheet">
    <script src="script.js" type="text/javascript"></script>
  </head>
  <body>
    <div id="header">
      <ol>
        <li>
          <a href="/home.html">Home</a>
        </li>
        <li>
          <a href="/about.html">About</a>
        </li>
        <li>
          <a href="/contact.html">Contact</a>
        </li>
      </ol>
    </div>
    <div class="body">
      <p>Lorem ipsum..</p>
    </div>
  </body>
</html>
```


Installation
------------

The recommended way to install `dominate` is with
[`pip`](http://pypi.python.org/pypi/pip/):

    pip install dominate

[![PyPI version](https://img.shields.io/pypi/v/dominate.svg?style=flat)](https://pypi.org/project/dominate/)
[![PyPI downloads](https://img.shields.io/pypi/dm/dominate.svg?style=flat)](https://pypi.org/project/dominate/)



Developed By
------------

* Tom Flanagan - <tom@zkpq.ca>
* Jake Wharton - <jakewharton@gmail.com>
* [Brad Janke](//github.com/bradj)

Git repository located at
[github.com/Knio/dominate](//github.com/Knio/dominate)


Examples
========

All examples assume you have imported the appropriate tags or entire tag set:

```python
from dominate.tags import *
```


Hello, World!
-------------

The most basic feature of `dominate` exposes a class for each HTML element, where the constructor
accepts child elements, text, or keyword attributes. `dominate` nodes return their HTML representation
from the `__str__`, `__unicode__`, and `render()` methods.

```python
print(html(body(h1('Hello, World!'))))
```
```html
<html>
    <body>
        <h1>Hello, World!</h1>
    </body>
</html>
```

Attributes
----------

`Dominate` can also use keyword arguments to append attributes onto your tags. Most of the attributes are a direct copy from the HTML spec with a few variations.

For attributes `class` and `for` which conflict with Python's [reserved keywords](http://docs.python.org/2/reference/lexical_analysis.html#keywords "Reserved Keywords"), you can use the following aliases:

| class | for |
|-------|-----|
|_class | _for |
|cls | fr |
|className|htmlFor|
|class_name|html_for|


```python
test = label(cls='classname anothername', fr='someinput')
print(test)
```
```html
<label class="classname anothername" for="someinput"></label>
```

Use `data_*` for [custom HTML5 data attributes](http://www.w3.org/html/wg/drafts/html/master/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes "HTML5 Data Attributes").

```python
test = div(data_employee='101011')
print(test)
```
```html
<div data-employee="101011"></div>
```

You can also modify the attributes of tags through a dictionary-like interface:

```python
header = div()
header['id'] = 'header'
print(header)
```
```html
<div id="header"></div>
```

Complex Structures
------------------

Through the use of the `+=` operator and the `.add()` method you can easily create more advanced structures.

Create a simple list:

```python
list = ul()
for item in range(4):
    list += li('Item #', item)
print(list)
```
```html
<ul>
    <li>Item #0</li>
    <li>Item #1</li>
    <li>Item #2</li>
    <li>Item #3</li>
</ul>
```

`dominate` supports iterables to help streamline your code:

```python
print(ul(li(a(name, href=link), __pretty=False) for name, link in menu_items))
```
```html
<ul>
    <li><a href="/home/">Home</a></li>
    <li><a href="/about/">About</a></li>
    <li><a href="/downloads/">Downloads</a></li>
    <li><a href="/links/">Links</a></li>
</ul>
```

A simple document tree:

```python
_html = html()
_body = _html.add(body())
header  = _body.add(div(id='header'))
content = _body.add(div(id='content'))
footer  = _body.add(div(id='footer'))
print(_html)
```
```html
<html>
    <body>
        <div id="header"></div>
        <div id="content"></div>
        <div id="footer"></div>
    </body>
</html>
```

For clean code, the `.add()` method returns children in tuples. The above example can be cleaned up and expanded like this:

```python
_html = html()
_head, _body = _html.add(head(title('Simple Document Tree')), body())
names = ['header', 'content', 'footer']
header, content, footer = _body.add([div(id=name) for name in names])
print(_html)
```
```html
<html>
    <head>
       <title>Simple Document Tree</title>
    </head>
    <body>
        <div id="header"></div>
        <div id="content"></div>
        <div id="footer"></div>
    </body>
</html>
```

You can modify the attributes of tags through a dictionary-like interface:

```python
header = div()
header['id'] = 'header'
print(header)
```
```html
<div id="header"></div>
```

Or the children of a tag though an array-line interface:

```python
header = div('Test')
header[0] = 'Hello World'
print(header)
```
```html
<div>Hello World</div>
```

Comments can be created using objects too!

```python
print(comment('BEGIN HEADER'))
```
```html
<!--BEGIN HEADER-->
```

```python
print(comment(p('Upgrade to newer IE!'), condition='lt IE9'))
```
```html
<!--[if lt IE9]>
  <p>Upgrade to newer IE!</p>
<![endif]-->
```

Rendering
---------

By default, `render()` tries to make all output human readable, with one HTML
element per line and two spaces of indentation.

This behavior can be controlled by the `__pretty` (default: `True` except for
certain element types like `pre`) attribute when creating an element, and by
the `pretty` (default: `True`), `indent` (default: `  `) and `xhtml` (default: `False`)
 arguments to `render()`. Rendering options propagate to all descendant nodes.

```python
a = div(span('Hello World'))
print(a.render())
```
```html
<div>
  <span>Hello World</span>
</div>
```
```python
print(a.render(pretty=False))
```
```html
<div><span>Hello World</span></div>
```
```python
print(a.render(indent='\t'))
```
```html
<div>
	<span>Hello World</span>
</div>
```
```python
a = div(span('Hello World'), __pretty=False)
print(a.render())
```
```html
<div><span>Hello World</span></div>
```
```python
d = div()
with d:
    hr()
    p("Test")
    br()
print(d.render())
print(d.render(xhtml=True))
```
```html
<div>
  <hr>
  <p>Test</p><br>
</div>
<div>
  <hr />
  <p>Test</p><br />
</div>
```


Context Managers
----------------

You can also add child elements using Python's `with` statement:

```python
h = ul()
with h:
    li('One')
    li('Two')
    li('Three')

print(h)
```
```html
<ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
</ul>
```


You can use this along with the other mechanisms of adding children elements, including nesting `with` statements, and it works as expected:

```python
h = html()
with h.add(body()).add(div(id='content')):
    h1('Hello World!')
    p('Lorem ipsum ...')
    with table().add(tbody()):
        l = tr()
        l += td('One')
        l.add(td('Two'))
        with l:
            td('Three')

print(h)
```
```html
<html>
    <body>
        <div id="content">
            <h1>Hello World!</h1>
            <p>Lorem ipsum ...</p>
            <table>
                <tbody>
                    <tr>
                        <td>One</td>
                        <td>Two</td>
                        <td>Three</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </body>
</html>
```

When the context is closed, any nodes that were not already added to something get added to the current context.

Attributes can be added to the current context with the `attr` function:

```python
d = div()
with d:
    attr(id='header')

 print(d)
 ```
 ```html
<div id="header"></div>
```

And text nodes can be added with the `dominate.util.text` function:

```python
from dominate.util import text
para = p(__pretty=False)
with para:
    text('Have a look at our ')
    a('other products', href='/products')

print(para)
```
```html
<p>Have a look at our <a href="/products">other products</a></p>
```


Decorators
----------

`Dominate` is great for creating reusable widgets for parts of your page. Consider this example:

```python
def greeting(name):
    with div() as d:
        p('Hello, %s' % name)
    return d

print(greeting('Bob'))
```
```html
<div>
    <p>Hello, Bob</p>
</div>
```

You can see the following pattern being repeated here:

```python
def widget(parameters):
    with tag() as t:
        ...
    return t
```

This boilerplate can be avoided by using tags (objects and instances) as decorators

```python
@div
def greeting(name):
    p('Hello %s' % name)
print(greeting('Bob'))
```
```html
<div>
    <p>Hello Bob</p>
</div>
```

The decorated function will return a new instance of the tag used to decorate it, and execute in a `with` context which will collect all the nodes created inside it.

You can also use instances of tags as decorators, if you need to add attributes or other data to the root node of the widget.
Each call to the decorated function will return a copy of the node used to decorate it.

```python
@div(h2('Welcome'), cls='greeting')
def greeting(name):
    p('Hello %s' % name)

print(greeting('Bob'))
```
```html

<div class="greeting">
    <h2>Welcome</h2>
    <p>Hello Bob</p>
</div>
```

Creating Documents
------------------

Since creating the common structure of an HTML document everytime would be excessively tedious dominate provides a class to create and manage them for you: `document`.

When you create a new document, the basic HTML tag structure is created for you.

```python
d = document()
print(d)
```
```html
<!DOCTYPE html>
<html>
    <head>
       <title>Dominate</title>
    </head>
    <body></body>
</html>
```

The `document` class accepts `title`, `doctype`, and `request` keyword arguments.
The default values for these arguments are `Dominate`, `<!DOCTYPE html>`, and `None` respectively.

The `document` class also provides helpers to allow you to access the `title`, `head`, and `body` nodes directly.

```python
d = document()
```

```python
>>> d.head
<dominate.tags.head: 0 attributes, 1 children>
>>> d.body
<dominate.tags.body: 0 attributes, 0 children>
>>> d.title
u'Dominate'
```


The `document` class also provides helpers to allow you to directly add nodes to the `body` tag.

```python
d = document()
d += h1('Hello, World!')
d += p('This is a paragraph.')
print(d)
```
```html
<!DOCTYPE html>
<html>
    <head>
       <title>Dominate</title>
    </head>
    <body>
        <h1>Hello, World!</h1>
        <p>This is a paragraph.</p>
    </body>
</html>
```

Embedding HTML
--------------

If 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:

```
from dominate.util import raw
...
td(raw('<a href="example.html">Example</a>'))
```

Without the raw call, this code would render escaped HTML with lt, etc.


SVG
---

The `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:

```python
from dominate.svg import *
print(circle(stroke_width=5))
```

```html
<circle stroke-width="5"></circle>
```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dominate",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.4",
    "maintainer_email": "",
    "keywords": "framework,templating,template,html,xhtml,python,html5",
    "author": "Jake Wharton",
    "author_email": "Tom Flanagan <tom@zkpq.ca>",
    "download_url": "https://files.pythonhosted.org/packages/80/e4/358a49a5567e38a12c56243f3a04642aebbbe4fe60e377e34d519f816c3e/dominate-2.9.0.tar.gz",
    "platform": null,
    "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![Python version](https://img.shields.io/pypi/pyversions/dominate.svg?style=flat)\n[![Build status](https://github.com/Knio/dominate/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Knio/dominate/actions/workflows/ci.yml?query=branch%3Amaster+)\n[![Coverage status](https://img.shields.io/coveralls/github/Knio/dominate/master.svg?style=flat)](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<!DOCTYPE html>\n<html>\n  <head>\n    <title>Dominate your HTML</title>\n    <link href=\"style.css\" rel=\"stylesheet\">\n    <script src=\"script.js\" type=\"text/javascript\"></script>\n  </head>\n  <body>\n    <div id=\"header\">\n      <ol>\n        <li>\n          <a href=\"/home.html\">Home</a>\n        </li>\n        <li>\n          <a href=\"/about.html\">About</a>\n        </li>\n        <li>\n          <a href=\"/contact.html\">Contact</a>\n        </li>\n      </ol>\n    </div>\n    <div class=\"body\">\n      <p>Lorem ipsum..</p>\n    </div>\n  </body>\n</html>\n```\n\n\nInstallation\n------------\n\nThe recommended way to install `dominate` is with\n[`pip`](http://pypi.python.org/pypi/pip/):\n\n    pip install dominate\n\n[![PyPI version](https://img.shields.io/pypi/v/dominate.svg?style=flat)](https://pypi.org/project/dominate/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/dominate.svg?style=flat)](https://pypi.org/project/dominate/)\n\n\n\nDeveloped By\n------------\n\n* Tom Flanagan - <tom@zkpq.ca>\n* Jake Wharton - <jakewharton@gmail.com>\n* [Brad Janke](//github.com/bradj)\n\nGit repository located at\n[github.com/Knio/dominate](//github.com/Knio/dominate)\n\n\nExamples\n========\n\nAll examples assume you have imported the appropriate tags or entire tag set:\n\n```python\nfrom dominate.tags import *\n```\n\n\nHello, World!\n-------------\n\nThe most basic feature of `dominate` exposes a class for each HTML element, where the constructor\naccepts child elements, text, or keyword attributes. `dominate` nodes return their HTML representation\nfrom the `__str__`, `__unicode__`, and `render()` methods.\n\n```python\nprint(html(body(h1('Hello, World!'))))\n```\n```html\n<html>\n    <body>\n        <h1>Hello, World!</h1>\n    </body>\n</html>\n```\n\nAttributes\n----------\n\n`Dominate` can also use keyword arguments to append attributes onto your tags. Most of the attributes are a direct copy from the HTML spec with a few variations.\n\nFor attributes `class` and `for` which conflict with Python's [reserved keywords](http://docs.python.org/2/reference/lexical_analysis.html#keywords \"Reserved Keywords\"), you can use the following aliases:\n\n| class | for |\n|-------|-----|\n|_class | _for |\n|cls | fr |\n|className|htmlFor|\n|class_name|html_for|\n\n\n```python\ntest = label(cls='classname anothername', fr='someinput')\nprint(test)\n```\n```html\n<label class=\"classname anothername\" for=\"someinput\"></label>\n```\n\nUse `data_*` for [custom HTML5 data attributes](http://www.w3.org/html/wg/drafts/html/master/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes \"HTML5 Data Attributes\").\n\n```python\ntest = div(data_employee='101011')\nprint(test)\n```\n```html\n<div data-employee=\"101011\"></div>\n```\n\nYou can also modify the attributes of tags through a dictionary-like interface:\n\n```python\nheader = div()\nheader['id'] = 'header'\nprint(header)\n```\n```html\n<div id=\"header\"></div>\n```\n\nComplex Structures\n------------------\n\nThrough the use of the `+=` operator and the `.add()` method you can easily create more advanced structures.\n\nCreate a simple list:\n\n```python\nlist = ul()\nfor item in range(4):\n    list += li('Item #', item)\nprint(list)\n```\n```html\n<ul>\n    <li>Item #0</li>\n    <li>Item #1</li>\n    <li>Item #2</li>\n    <li>Item #3</li>\n</ul>\n```\n\n`dominate` supports iterables to help streamline your code:\n\n```python\nprint(ul(li(a(name, href=link), __pretty=False) for name, link in menu_items))\n```\n```html\n<ul>\n    <li><a href=\"/home/\">Home</a></li>\n    <li><a href=\"/about/\">About</a></li>\n    <li><a href=\"/downloads/\">Downloads</a></li>\n    <li><a href=\"/links/\">Links</a></li>\n</ul>\n```\n\nA simple document tree:\n\n```python\n_html = html()\n_body = _html.add(body())\nheader  = _body.add(div(id='header'))\ncontent = _body.add(div(id='content'))\nfooter  = _body.add(div(id='footer'))\nprint(_html)\n```\n```html\n<html>\n    <body>\n        <div id=\"header\"></div>\n        <div id=\"content\"></div>\n        <div id=\"footer\"></div>\n    </body>\n</html>\n```\n\nFor clean code, the `.add()` method returns children in tuples. The above example can be cleaned up and expanded like this:\n\n```python\n_html = html()\n_head, _body = _html.add(head(title('Simple Document Tree')), body())\nnames = ['header', 'content', 'footer']\nheader, content, footer = _body.add([div(id=name) for name in names])\nprint(_html)\n```\n```html\n<html>\n    <head>\n       <title>Simple Document Tree</title>\n    </head>\n    <body>\n        <div id=\"header\"></div>\n        <div id=\"content\"></div>\n        <div id=\"footer\"></div>\n    </body>\n</html>\n```\n\nYou can modify the attributes of tags through a dictionary-like interface:\n\n```python\nheader = div()\nheader['id'] = 'header'\nprint(header)\n```\n```html\n<div id=\"header\"></div>\n```\n\nOr the children of a tag though an array-line interface:\n\n```python\nheader = div('Test')\nheader[0] = 'Hello World'\nprint(header)\n```\n```html\n<div>Hello World</div>\n```\n\nComments can be created using objects too!\n\n```python\nprint(comment('BEGIN HEADER'))\n```\n```html\n<!--BEGIN HEADER-->\n```\n\n```python\nprint(comment(p('Upgrade to newer IE!'), condition='lt IE9'))\n```\n```html\n<!--[if lt IE9]>\n  <p>Upgrade to newer IE!</p>\n<![endif]-->\n```\n\nRendering\n---------\n\nBy default, `render()` tries to make all output human readable, with one HTML\nelement per line and two spaces of indentation.\n\nThis behavior can be controlled by the `__pretty` (default: `True` except for\ncertain element types like `pre`) attribute when creating an element, and by\nthe `pretty` (default: `True`), `indent` (default: `  `) and `xhtml` (default: `False`)\n arguments to `render()`. Rendering options propagate to all descendant nodes.\n\n```python\na = div(span('Hello World'))\nprint(a.render())\n```\n```html\n<div>\n  <span>Hello World</span>\n</div>\n```\n```python\nprint(a.render(pretty=False))\n```\n```html\n<div><span>Hello World</span></div>\n```\n```python\nprint(a.render(indent='\\t'))\n```\n```html\n<div>\n\t<span>Hello World</span>\n</div>\n```\n```python\na = div(span('Hello World'), __pretty=False)\nprint(a.render())\n```\n```html\n<div><span>Hello World</span></div>\n```\n```python\nd = div()\nwith d:\n    hr()\n    p(\"Test\")\n    br()\nprint(d.render())\nprint(d.render(xhtml=True))\n```\n```html\n<div>\n  <hr>\n  <p>Test</p><br>\n</div>\n<div>\n  <hr />\n  <p>Test</p><br />\n</div>\n```\n\n\nContext Managers\n----------------\n\nYou can also add child elements using Python's `with` statement:\n\n```python\nh = ul()\nwith h:\n    li('One')\n    li('Two')\n    li('Three')\n\nprint(h)\n```\n```html\n<ul>\n    <li>One</li>\n    <li>Two</li>\n    <li>Three</li>\n</ul>\n```\n\n\nYou can use this along with the other mechanisms of adding children elements, including nesting `with` statements, and it works as expected:\n\n```python\nh = html()\nwith h.add(body()).add(div(id='content')):\n    h1('Hello World!')\n    p('Lorem ipsum ...')\n    with table().add(tbody()):\n        l = tr()\n        l += td('One')\n        l.add(td('Two'))\n        with l:\n            td('Three')\n\nprint(h)\n```\n```html\n<html>\n    <body>\n        <div id=\"content\">\n            <h1>Hello World!</h1>\n            <p>Lorem ipsum ...</p>\n            <table>\n                <tbody>\n                    <tr>\n                        <td>One</td>\n                        <td>Two</td>\n                        <td>Three</td>\n                    </tr>\n                </tbody>\n            </table>\n        </div>\n    </body>\n</html>\n```\n\nWhen the context is closed, any nodes that were not already added to something get added to the current context.\n\nAttributes can be added to the current context with the `attr` function:\n\n```python\nd = div()\nwith d:\n    attr(id='header')\n\n print(d)\n ```\n ```html\n<div id=\"header\"></div>\n```\n\nAnd text nodes can be added with the `dominate.util.text` function:\n\n```python\nfrom dominate.util import text\npara = p(__pretty=False)\nwith para:\n    text('Have a look at our ')\n    a('other products', href='/products')\n\nprint(para)\n```\n```html\n<p>Have a look at our <a href=\"/products\">other products</a></p>\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\n<div>\n    <p>Hello, Bob</p>\n</div>\n```\n\nYou can see the following pattern being repeated here:\n\n```python\ndef widget(parameters):\n    with tag() as t:\n        ...\n    return t\n```\n\nThis boilerplate can be avoided by using tags (objects and instances) as decorators\n\n```python\n@div\ndef greeting(name):\n    p('Hello %s' % name)\nprint(greeting('Bob'))\n```\n```html\n<div>\n    <p>Hello Bob</p>\n</div>\n```\n\nThe decorated function will return a new instance of the tag used to decorate it, and execute in a `with` context which will collect all the nodes created inside it.\n\nYou can also use instances of tags as decorators, if you need to add attributes or other data to the root node of the widget.\nEach call to the decorated function will return a copy of the node used to decorate it.\n\n```python\n@div(h2('Welcome'), cls='greeting')\ndef greeting(name):\n    p('Hello %s' % name)\n\nprint(greeting('Bob'))\n```\n```html\n\n<div class=\"greeting\">\n    <h2>Welcome</h2>\n    <p>Hello Bob</p>\n</div>\n```\n\nCreating Documents\n------------------\n\nSince creating the common structure of an HTML document everytime would be excessively tedious dominate provides a class to create and manage them for you: `document`.\n\nWhen you create a new document, the basic HTML tag structure is created for you.\n\n```python\nd = document()\nprint(d)\n```\n```html\n<!DOCTYPE html>\n<html>\n    <head>\n       <title>Dominate</title>\n    </head>\n    <body></body>\n</html>\n```\n\nThe `document` class accepts `title`, `doctype`, and `request` keyword arguments.\nThe default values for these arguments are `Dominate`, `<!DOCTYPE html>`, and `None` respectively.\n\nThe `document` class also provides helpers to allow you to access the `title`, `head`, and `body` nodes directly.\n\n```python\nd = document()\n```\n\n```python\n>>> d.head\n<dominate.tags.head: 0 attributes, 1 children>\n>>> d.body\n<dominate.tags.body: 0 attributes, 0 children>\n>>> d.title\nu'Dominate'\n```\n\n\nThe `document` class also provides helpers to allow you to directly add nodes to the `body` tag.\n\n```python\nd = document()\nd += h1('Hello, World!')\nd += p('This is a paragraph.')\nprint(d)\n```\n```html\n<!DOCTYPE html>\n<html>\n    <head>\n       <title>Dominate</title>\n    </head>\n    <body>\n        <h1>Hello, World!</h1>\n        <p>This is a paragraph.</p>\n    </body>\n</html>\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('<a href=\"example.html\">Example</a>'))\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<circle stroke-width=\"5\"></circle>\n```\n\n",
    "bugtrack_url": null,
    "license": "LGPL-3.0-or-newer",
    "summary": "Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API.",
    "version": "2.9.0",
    "project_urls": {
        "Homepage": "https://github.com/Knio/dominate",
        "Source": "https://github.com/Knio/dominate"
    },
    "split_keywords": [
        "framework",
        "templating",
        "template",
        "html",
        "xhtml",
        "python",
        "html5"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c31ad495284b8dbcc620eb8bf7810194ded1d3edf3c912ed0208e0be49d74915",
                "md5": "422557e4c48f74c26f9f082543ad3a0b",
                "sha256": "2346cc27dc0fd9d279abd004b29da80ee294782619d1ca1aaccf4fb02439e6f8"
            },
            "downloads": -1,
            "filename": "dominate-2.9.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "422557e4c48f74c26f9f082543ad3a0b",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.4",
            "size": 29412,
            "upload_time": "2023-11-16T05:47:26",
            "upload_time_iso_8601": "2023-11-16T05:47:26.149707Z",
            "url": "https://files.pythonhosted.org/packages/c3/1a/d495284b8dbcc620eb8bf7810194ded1d3edf3c912ed0208e0be49d74915/dominate-2.9.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "80e4358a49a5567e38a12c56243f3a04642aebbbe4fe60e377e34d519f816c3e",
                "md5": "946eeb2193804230ec68aee9ddaa77c0",
                "sha256": "b15791ebea432218543a1702d76ae45d2ff95ff994e52014b8686a69dad772fd"
            },
            "downloads": -1,
            "filename": "dominate-2.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "946eeb2193804230ec68aee9ddaa77c0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.4",
            "size": 36289,
            "upload_time": "2023-11-16T05:47:28",
            "upload_time_iso_8601": "2023-11-16T05:47:28.187809Z",
            "url": "https://files.pythonhosted.org/packages/80/e4/358a49a5567e38a12c56243f3a04642aebbbe4fe60e377e34d519f816c3e/dominate-2.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-16 05:47:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Knio",
    "github_project": "dominate",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dominate"
}
        
Elapsed time: 0.57084s