A Python-based HTML builder with built-in SEO, accessibility, layout injection, and optional minification.
Project description
Fubam
🧩 Best Python Frontend Generator — Lightweight, Fast & Pure Python
- Version: 0.1.0 (Stable)
- Release: 12 July 2025
- Author: Aman Ali
- License: MIT
Fubam — Functions-based Markup for Python — is a minimal, fast, and flexible HTML frontend builder using only Python.
It supports layouts, components, conditionals, and SEO optimizations — without writing a single line of raw HTML.
🔧 Setup
📦 Installation
git clone https://github.com/DeveloperAmanAli/fubam.git
Fubam is framework-independent and works with Flask, Django, or any Python web server.
⚙️ Usage
Basic Folder Structure
project/
│
├── templates/
│ ├── layout.pmx
│ ├── page.pmx
│ └── component.pmx
├── main.py
└── fubam/
main.py
import fubam
fubam = fubam.Fubam(template_dir="./templates", SEO=True, Accessibility=True)
output = fubam.compile("page", resources={"username": "Aman", "time": "4:05 PM"})
print(output)
layout.pmx
Export = html(
head(title("Layout File")),
body(
div({"class": "container"},
__extend__, # Inject child page here
h6(_time)
)
)
)
components.pmx
Export = div(
h4("Reusable Footer Component"),
p("© 2025 Fubam Inc.")
)
page.pmx
p = div(
h2(f"Hello, {username}"),
useComponent("components"), # Imported component
img({"src": "/profile.png"})
)
Export = useLayout("layout", wrapper(p), resources={"_time": time})
🧠 How It Works
Fubam templates are just Python files that use fubam's built-in tag functions (div(), p(), img()...).
Fubam will:
- Parse your
.pmxfile - Build a complete HTML string
- Inject SEO/Accessibility/meta/layout enhancements (based on config)
🧪 Template Syntax Basics
| Concept | HTML | Fubam Equivalent |
|---|---|---|
| Tag | <div></div> |
div() |
| Attribute | <div class="box"> |
div({"class": "box"}) |
| Nesting | <div><h1>Hi</h1></div> |
div(h1("Hi")) |
| Text Content | <p>Hello</p> |
p("Hello") |
| Loops | — | [div(user.name) for user in users] |
| Conditionals | — | HTML = comp1 if cond else comp2 |
⚡ Features
- 🔁 Component-based structure with
useComponent - 🧱 Layout system with
useLayout - 🧠 Full Python logic (loops, conditionals, variables)
- 🔍 Built-in SEO tag injection (title, meta)
- 🌐 Accessibility enhancements (alt, doctype, lang)
- 🚀 JS/CSS auto inlining (optional)
- 🧼 Minification for styles/scripts (optional)
- 📁 Static pre-compilers:
compressJSFile()&compressCSSFile()
🧩 Advanced: Components
components.py:
Footer = footer(
div("Links Section"),
div("© 2024 Fubam Inc.")
)
In your page:
comp = useComponent("component")
Export = body(
div("Main Content"),
comp
)
🧪 Loops Example
def userCard(name, age):
return div(
h2(f"Name: {name}"),
p(f"Age: {age}")
)
Export = div(
[userCard(p["name"], p["age"]) for p in persons]
)
🔄 Conditionals Example
Export = page_content if loggedin else render_component("login")
🌟 SEO & Performance
SEO Mode (SEO=True)
-
Adds
<title>if missing -
Injects standard SEO meta tags:
viewport,description,keywords,charset,X-UA-Compatible
Accessibility Mode (Accessibility=True)
- Adds
alt="..."to images - Forces
<!DOCTYPE html> - Adds
lang="en"to<html>
Performance Mode (Performance=True)
- Adds
loading="lazy"to<img>by default
📦 Static Minification
Fubam includes tools to minify CSS and JS before deployment.
compressCSSFile("style.css")
compressJSFile("script.js")
Output will be:
style.min.cssscript.min.js
You can also pass custom output paths.
⚙️ Default Configs
Fubam(
template_dir="templates",
SEO=True,
Accessibility=True,
Performance=True,
InjectCSS=False,
InjectJS=False,
MinifyStyleTags=True,
MinifyScriptTags=True
)
✅ Precautions
<input />is defined asinp()notinput()- ⚠️ Do not use
input()or interactive logic in.pmxtemplates. - Always define
Export = ...in your templates. - You can use
Export = ...in components if they’re used withuseComponent.
❤️ Why Fubam?
- Zero learning curve if you know Python
- Full control: loops, conditions, variables
- Clean & structured frontend without markup
- No external dependencies
- Works anywhere Python runs
🔗 Links
📜 License
MIT License — © Aman Ali
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fubam-0.1.0.tar.gz.
File metadata
- Download URL: fubam-0.1.0.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e62a57830567e3f274a7aa2cbc93ba6a235ad0659900a3996bcd79541e43dee
|
|
| MD5 |
8325e0b5881396ba838940ae3cdc6007
|
|
| BLAKE2b-256 |
6dda6148675399674cf413133beecddcf9c5ec04d0921111766cd778f6edfb04
|
File details
Details for the file fubam-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fubam-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0e01e9d6318324534c065db903c01b0408ee7da231b867019bdc9bb1a5cfdbc
|
|
| MD5 |
8211d8951cc6068e12cdd00220159d08
|
|
| BLAKE2b-256 |
86ec65c9b0b9e1ff984d2ef2656cf8c677b562b9bf8ccfcd1046b86227dcd316
|