Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dax-dot-gay/html-creator
Python library to dynamically generate html in an etree-like structure
https://github.com/dax-dot-gay/html-creator
Last synced: 6 days ago
JSON representation
Python library to dynamically generate html in an etree-like structure
- Host: GitHub
- URL: https://github.com/dax-dot-gay/html-creator
- Owner: dax-dot-gay
- License: mit
- Created: 2019-05-13T16:55:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-14T17:51:49.000Z (over 3 years ago)
- Last Synced: 2024-10-11T09:23:38.703Z (about 1 month ago)
- Language: Python
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# html-creator
Python library to dynamically generate html in an etree-like structure## Installation
Run `pip install html-creator` or download zip/clone# 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 document
- `Document.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)` or `Element.add_child(new Element object instance)` adds a child Element to the Element
## Properties
- `tag`, `attrs`, `content`: See Args
- `children`: 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]` and `CSS[selector]`, respectively, delete and get the specified selector in the CSS object
- `add_sel(selector)`: Adds a selector to add properties to
- `add_property(selector, property, value)`: Adds property `property` with value `value` to selector `selector`
- `del_property(selector, property)`: Deletes property `property` from selector `selector`
- `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