Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

# HTMLy Elm inspired HTML generator for Python.

## From the doctest. Creating a tag.

>>> tag = div([], [])
>>> render(tag)
'<div ></div>'

Creating a self closing tag. >>> render(hr([])) ‘<hr />’

Tag can have a content. >>> render(div([], [text(‘content’)])) ‘<div >content</div>’ >>> render(text(‘content’)) ‘content’

You can use some attributes for the tag. >>> render(div([lang(‘tr’), id_(‘content’), class_(‘bar’), attribute(‘data-value’, ‘foo’)], [])) ‘<div lang=”tr” id=”content” class=”bar” data-value=”foo”></div>’

You can have them both. >>> render(div([lang(‘tr’)], [text(‘content’)])) ‘<div lang=”tr”>content</div>’

You can have more content. >>> render(div([], [ nav([], []), text(‘Hello’), hr([])])) ‘<div ><nav ></nav>Hello<hr /></div>’

You can now start having composable abstractions as below. You can have your own list item which takes content, without need of extra attributes and list syntax for content. >>> _li = lambda item: li([], [text(item)]) >>> litems = lambda items: [_li(item) for item in items ]

Abstracting again just because we can. >>> _ul = lambda items: ul([], litems(items)) >>> render(_ul([‘Bob’, ‘Mary’, ‘Joe’])) ‘<ul ><li >Bob</li><li >Mary</li><li >Joe</li></ul>’

Nested Elements >>> render(div([], [div([], [p([], [text(‘a paragraph’)])])])) ‘<div ><div ><p >a paragraph</p></div></div>’

>>> render(html([],
...             [ head([],
...                    [ title([],
...                            [text('Awesome Website')]),
...                      script([src('/script.js')], [])
...                    ]),
...               body([],
...                    [ header([],
...                             [ img([src('/logo.png')]) ]),
...                      div([], [text('Content Here')]),
...                      footer([],
...                             [hr([]),
...                              text('Copyright 2019')])
...                      ])
...               ]))
'<html ><head ><title >Awesome Website</title><script src="/script.js"></script></head><body ><header ><img src="/logo.png"/></header><div >Content Here</div><footer ><hr />Copyright 2019</footer></body></html>'

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htmly-0.3dev.tar.gz (2.3 kB view details)

Uploaded Source

File details

Details for the file htmly-0.3dev.tar.gz.

File metadata

  • Download URL: htmly-0.3dev.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for htmly-0.3dev.tar.gz
Algorithm Hash digest
SHA256 169523a31d41864b9fcc7648850011dcf1e156bcde36dfab5a4d537173c18180
MD5 15f7ca65cfd2660a33f3f12a77202643
BLAKE2b-256 7847600191509c0161ef8c4ea07bb304496207f877a9effc1c27b390756920b6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3dev This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page