Skip to main content

A declarative, type-safe ,Python-Native template Rendering Framework and Meta-framework for Django.

Project description

🐘 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>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mastodon_ui-1.0.5.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mastodon_ui-1.0.5-py3-none-any.whl (133.5 kB view details)

Uploaded Python 3

File details

Details for the file mastodon_ui-1.0.5.tar.gz.

File metadata

  • Download URL: mastodon_ui-1.0.5.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for mastodon_ui-1.0.5.tar.gz
Algorithm Hash digest
SHA256 5e1ee77d4a833400bff133439f06a1a44c05ac89cb6c021f1a64f0955ef039cd
MD5 6aa32401dee097b492c6cba3ba35c29e
BLAKE2b-256 7119c9d753767293ce51d0b56362f7b774c4fa106854ba5cb948a3d12740d3f9

See more details on using hashes here.

File details

Details for the file mastodon_ui-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: mastodon_ui-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 133.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for mastodon_ui-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 03a1fad3e0021e894c15a51ac6b710ec813c78f137d8e18a067bacdef3dd8307
MD5 ee5450662b439fe0a57f1ab4177c2747
BLAKE2b-256 11e608d33d4ca8e191c339640824996b5e8ddaed388b378edde9504231c3da54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page