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>'
Metadata
Release files for htmly 0.3dev
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| htmly-0.3dev.tar.gz | 2.3 kB | Details |
Release files / htmly-0.3dev.tar.gz
| Download URL | htmly-0.3dev.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
169523a31d41864b9fcc7648850011dcf1e156bcde36dfab5a4d537173c18180
|
|
BLAKE2b-256 checksum How to use checksums |
7847600191509c0161ef8c4ea07bb304496207f877a9effc1c27b390756920b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|