Winged-Python is an innovative Domain-Specific Language (DSL) library for efficient HTML writing in Python. Mirroring its Swift counterpart, Winged-Python is based on the DSL concept, focusing on simplification and specificity in HTML generation. Using the Composite design pattern, the library enables developers to construct HTML structures in a logical, organized, and reusable manner.
This library is created to be fully independent, not requiring integration with specific server frameworks or front-end libraries. This offers developers the freedom to use Winged-Python across a variety of projects, from simple static pages to complex web applications, keeping the code clean, readable, and efficient.
https://pypi.org/project/winged-python/
- Releases Page
pip install winged-python==0.1.0
from winged.HTML.div import Div
from winged.HTML.h import H
from winged.HTML.table import Table
from winged.HTML.string import String
divC = Div(("class", "container"))
h = H("1")
h.add(String("Hello World"))
divC.add(h)
table = Table()
table.add_table_headers(["Name", "Age", "Height", "Location"]) # Define headers
table.add_row()
table.add_in_row(String("John"))
table.add_in_row(String("25"))
table.add_in_row(String("1.80"))
table.add_in_row(String("New York"))
table.add_row()
table.add_in_row(String("Maria"))
table.add_in_row(String("23"))
table.add_in_row(String("1.50"))
table.add_in_row(String("New Jersey"))
divC.add(table)
print(divC.generate())
<div class="container">
<h1>Hello World</h1>
<table>
<thead>
<th>Name</th>
<th>Age</th>
<th>Height</th>
<th>Location</th>
</thead>
<tbody>
<tr>
<td>John</td>
<td>25</td>
<td>1.80</td>
<td>New York</td>
</tr>
<tr>
<td>Maria</td>
<td>23</td>
<td>1.50</td>
<td>New Jersey</td>
</tr>
</tbody>
</table>
</div>
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from winged.HTML.div import Div
from winged.HTML.h import H
from winged.HTML.string import String
@app.get('/', response_class=HTMLResponse)
async def home():
divC = Div(("class", "container"))
h = H("1")
h.add(String("Hello World"))
divC.add(h)
return divC.get_string() # Return HTML String
To contribute, it's simple, follow the guidelines below to prepare your development environment
User OS terminal or IDE terminal
python3 -m venv venv
source venv/bin/activate
.\venv\Scripts\activate.bat
.\venv\Scripts\activate.ps1`
python3 -m pip install -r requirements.txt
pytest
- Make documentation with Sphinx