pypertext 0.1.1

Creator: codyrutscher

Last updated:

Add to Cart

Description:

pypertext 0.1.1

Pypertext
Transform a Python dictionary to HTML string.
Install
Requires python 3.6+
pip install pypertext

Usage
The render_element function taks a dictionary and returns a string.
el = {
"tag": "div",
"attrs": {
"class": "container",
},
"children": [
{
"tag": "h1",
"children": "Hello World!",
},
{
"tag": "p",
"children": "This is a paragraph.",
},
],
}
expected = '<div class="container"><h1>Hello World!</h1><p>This is a paragraph.</p></div>'
out = render_element(el)
assert out == expected

The render_document function takes a dictionary or list and returns a full HTML document as a string.
el = {
"tag": "div",
"attrs": {
"class": "container",
},
"children": [
{
"tag": "h1",
"children": "Hello World!",
},
],
}
expected = '<!DOCTYPE html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/></head><body><div class="container"><h1>Hello World!</h1></div></body></html>'
out = render_document(body=el)
assert out == expected

Tasks
Use the xc task runner to execute the commands below.
build-dist
rm -rf ./dist
python setup.py sdist

clean
Delete build artifacts
rm -rf dist/ pypertext.egg-info/ site/ build/
rm -rf ./pypertext/*.so
rm -rf ./pypertext/__pycache__/
rm -rf ./pypertext_sessions.db

upload-pypi
twine upload --repository pypi dist/*

upload-testpypi
twine upload --repository testpypi dist/*

install-dev
rm -rf ./pypertext.egg-info
python -m pip uninstall -y pypertext
python -m pip install -e .[dev]

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.