Skip to main content

🐘 Mastodon UI (mui)

A Python-Native Template Rendering Framework and Meta-framework for Django. Write Type-Safe HTML, CSS, and Logic in pure Python. No context switching. No template spaghetti.

PyPI version License: MIT Tests Python

Ko-fi

...

🐘 Mastodon UI (mui)

A Python-Native Template Rendering Framework and Meta-framework for Django. Write Type-Safe HTML, CSS, and Logic in pure Python. No context switching. No template spaghetti.

📣 Version 1.0.0 is Live!

MUI has officially reached stable v1 status. It is a backend-first framework that transforms Python objects into performant HTML/CSS, creating a seamless bridge between Django's backend logic and the frontend interface.

📚 Read the Full Sample Documentation (v1.0)

Click the link above for deep dives into : view sample documentation

The Component Architecture: Brain (State) / Body (Elements) / Skin (Style).

Shortcuts for building complex UIs.

Mastodon Forms: Automatic Django Form rendering.

JIT Styling: How the CSS engine works.

⚡ Purpose & Philosophy

Traditional Django development often requires context-switching between Python (views.py) and HTML/Jinja (templates/). Logic gets split, and typos in templates cause runtime errors.

MUI solves this by bringing the Frontend into Python:

🧠 Type-Safe UI: Write HTML in Python. If your code compiles, your HTML is valid.

🎨 Just-In-Time (JIT) CSS: Styles live with components. MUI scans your active components and generates a minified CSS bundle on the fly. No unused styles.

🛡️ Logic Gates: Built-in State Management. Components automatically hide themselves if required data (like user.is_authenticated) or permissions are missing.

🔌 Django Native: Deep integration with Django Forms and Requests via the RDT (Request Data Transformer).

📦 Installation

pip install mastodon-ui 

🚀 Quick Example

Here is how you build a reusable, styled component using the Flow API:

def user_card(username):
    # 1. Define Logic (The Brain)
    # "Look for 'name' in dynamic data. If missing, don't render."
    user_id = 'User_789xyz1323'
    user_info = {'practical-info':['python','javascript','docker','django']}
    li_el = ElementState('li', d_state='practical-info',i_state=True, strict_dynamic=True,)
    user_comp_state = ComponentState(
        s_data={},
        d_data=user_info,
        li_el,
    )
    # 2. Build Component (Structure + Style + Data)
    card = Component(
        name="UserCard",
        template=f"<div class='card'>{h1(username,strong(user_id))+ul(li_el.placeholder)}</div>",
        # Inject Data
        state=user_comp_state,
    )

    return card

# Render it
html= user_card("Admin").render()
print(html)
# Output: 
# <div class='card'><h1>Admin<strong>User_789xyz1323</strong></h1><ul><li>python</li><li>javascript</li><li>docker</li><li>django</li></ul></div>

Metadata

Release files for mastodon-ui 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mastodon-ui 1.0.6
File Size Uploaded
mastodon_ui-1.0.6.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mastodon-ui 1.0.6
File Interpreter ABI Platform
mastodon_ui-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 1.7 MB

Release files / mastodon_ui-1.0.6.tar.gz

Download URL mastodon_ui-1.0.6.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
f0fba34068815b62931846b08ce78dd993bc24e89c066cabb211597ee70bc691
BLAKE2b-256 checksum
How to use checksums
70ee02e06eab1d3dfc74ee346db8958ea4b272de2c6110a663196cc418ab3d2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / mastodon_ui-1.0.6-py3-none-any.whl

Download URL mastodon_ui-1.0.6-py3-none-any.whl
Size 133.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a70ef58dca9d7bbbecdb46e895d3a35fd6dc639d2933e2b024dadf2c59569381
BLAKE2b-256 checksum
How to use checksums
1f72f4a2a0f6d96ded1b11e37a38b4d16b1dceb7a3505f08ba0dc99dfbb2a705
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page