Translate Python Code to HTML
Project description
piNet
Translate Python Code to HTML
piNet is a python module built to work with seamlessly Web Development frameworks like Django and Flask. This module renders Python code to HTML
Features
- Compatible with Python 3
- Supports all tags and global attributes supported by HTML 5
- HTML files can either be rendered or can be exported from Python File
- Does not require any dependencies to be installed
Installation
piNet requires Python 3 to run so make sure you're using latest version of PIP and Python
pip install piNet
Usage
Place attributes to HTML tags in parameters to the corresponding initializer of the tag. In case of closing tag, render function takes contents between opening and closing tag. In other cases render function takes no parameters.
Due to conflict with Python keywords name of some tags or attributes have been changes as below.
- 'class' attribute can be accessed by 'clas' parameter.
- 'del' tag can be accessed by 'delete' subclass of HTML tag
...More will be listed
from pinet import *
object = html("Hello World") # Generates HTML object with 'Hello World' as Title
page_to_be_exported = object.render(
object.h1(name="heading_1", id="heading_1", clas="heading_1").render(
object.p(name="paragraph", id="paragraph", clas="paragraph").render(
"Text in first Paragraph"
),
object.a(href="https://any_link", target='_blank').render(
object.p(name="paragraph", id="paragraph", clas="paragraph").render(
"Text in Second Paragraph"
)
)
)
)
export_html(page_to_be_exported, 'filename.html')
Above code generates a HTML file in current working directory named filename.html
The contnts of the file would be as follows
<!DOCTYPE html>
<html>
<head>
<title>Hello world</title>
</head>
<body>
<h1 name="heading_1" id="heading_1" class="heading_1">
<p name="paragraph" id="paragraph" class="paragraph">
Text in first Paragraph
</p>
<a href="https://any_link" target="_blank">
<p name="paragraph" id="paragraph" class="paragraph">
Text in Second Paragraph
</p>
</a>
</h1>
</body>
</html>
Bugs
Since module is still in Beta testing so few tags are yet to be added. Please let me knnow if you encounter any bug, crash, etc. or If you have any suggestion feel free to let me know.
Caution
License
GNU General Public License
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 Distributions
Built Distribution
File details
Details for the file pinet-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: pinet-0.2.4-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0996629e46b8f00fb67ed5f67878f5d177cf7552616c5d2619d568d875db7abb |
|
MD5 | 1616b95d4e37b8245a713cbdb6abc4cd |
|
BLAKE2b-256 | ad168899e80b3847a5f9e6f1991a2bb2ba190dbde509aa8eac121f8d9e49b59e |