Dynamic HTML code generation
Project description
html-creator
Python library to dynamically generate html in an etree-like structure
Docs
Document(title='')
: Your HTML document.
Args
- title: The title of your document. This is optional and can be specified later
Methods
- Using
str()
on this object will return the formatted html content of the Document.
Properties
Document.children
: The direct children of the documentDocument.head
: The head tag of the document (automatically generated)Document.body
: The body tag of the document (automatically generated)
Element(tag='p',attrs={},content='')
: A single HTML element/tag
Args
- tag: The tag name, like div, p, or h1
- attrs: The attributes of the element, in a dict
- content: Text content of your tag
Methods
- Using
str()
on this object will return the formatted html tag, including formatted html versions of all child tags - Using
len(Element object)
will return the number of children - Using
Element[index]
will return the element at that index - Using
Element.append(new Element object instance)
orElement.add_child(new Element object instance)
adds a child Element to the Element
Properties
tag
,attrs
,content
: See Argschildren
: The direct children on the Element
CSS(Dict={})
: A utility class for generating CSS
Args
- Dict: Specifies a starting dictionary (Must be in form
{selector: {property: value,property: value,property: value}, selector2: {property: value,property: value,property: value}}
)
Methods
del CSS[selector]
andCSS[selector]
, respectively, delete and get the specified selector in the CSS objectadd_sel(selector)
: Adds a selector to add properties toadd_property(selector, property, value)
: Adds propertyproperty
with valuevalue
to selectorselector
del_property(selector, property)
: Deletes propertyproperty
from selectorselector
str(CSS object)
: Returns a formatted CSS string
Properties
dict
: The dictionary used by the CSS object. Can be edited directly, but could cause issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
html_creator-1.0.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for html_creator-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1b60fe36667cbaf7604abbf14a77f7ae7b32978db11d68ef7ac5001484d842a |
|
MD5 | 2b91e77b787ed32cb0f12a6ba157e711 |
|
BLAKE2b-256 | 9022c7241bf07175a7debc1694fe726b1b90346f6bb100121aad9b810e9d2cd5 |