Skip to main content

Flask / Quart themes

License Pypi Python Versions

Flask / Quart tools for creating themes.

Install

> pip install flask-quart-themes

Setup

Flask

from flask import Flask, render_template

from flask_theming.setup_flask import setup_flask_themes
from flask_theming.decorators_flask import page_title, menu_entry

app = Flask(__name__)

setup_flask_themes(app, title_default="Plak")

@page_title("Users zone")
@menu_entry("users::home")
def index():
    return render_template("user_home.html")

@page_title("Dashboard")
@menu_entry("dashboard", icon="fa fa-dashboard")
def dashboard():
    return render_template("dashboard.html")

NOTE: This only works in Flask < 2.3!

Quart

from quart import Quart, render_template

from flask_theming.setup_quart import setup_quart_themes
from flask_theming.decorators_quart import page_title, menu_entry


app = Quart(__name__)
setup_quart_themes(app, title_default="Plak")

@page_title("Users zone")
@menu_entry("users::home")
async def user():
    return await render_template("user_home.html")

@page_title("Dashboard")
@menu_entry("dashboard", icon="fa fa-dashboard")
async def dashboard():
    return await render_template("dashboard.html")

Jinja utils

Title

<!DOCTYPE html>
<html lang="es">
<head>
    <title>{{ theme_title }}</title>
</head>

Menu

<nav class="sidenav shadow-right sidenav-light">
    <div class="nav accordion" id="accordionSidenav">

        {% set dashboard = theme_menu.get_entry("dashboard") %}
        
        <a class="nav-link" href="{{ url_for(dashboard.path) }}">
            <!-- ########### -->
            <!-- IT WILL PRINT: 'fa fa-dashboard' -->
            <div class="nav-link-icon"><i class="{{ dashboard.icon }}"></i></div>
            <!-- ########### -->
            
            <!-- ########### -->
            <!-- IT WILL PRINT: 'dashboard' -->
            {{ dashboard.title }}
            <!-- ########### -->
        </a>
        
        <!-- User zone menu -->
        
        {% for menu in theme_menu.get_menu("users-zone") %}
        <a class="nav-link collapsed" data-bs-toggle="collapse" data-bs-target="#collapseDashboards" aria-expanded="false" aria-controls="collapseDashboards">
            <div class="nav-link-icon"><i data-feather="users"></i></div>
            
            <!-- ########### -->
            <!-- IT WILL PRINT: 'Users' -->
            {{ menu.header }}
            <!-- ########### -->
            
            <div class="sidenav-collapse-arrow"><i class="fas fa-angle-down"></i></div>
        </a>
        <div class="collapse" id="collapseDashboards" data-bs-parent="#accordionSidenav">
            <nav class="sidenav-menu-nested nav accordion" id="accordionSidenavPages">
                
                <!-- ########### -->
                <!-- IT WILL GET ALL 'Users' paths -->
                {% for entry in menu.entries %}
                    <a class="nav-link" href="{{ url_for(entry.path) }}">{{ entry.title }}</a>
                {% endfor %}
                <!-- ########### -->
                
            </nav>
        </div>
    {% endfor %}
     </div>
</nav>
{{ menu() }}

Metadata

Release files for flask-quart-themes 1.0.0

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

Source distribution (sdist)

Source distribution for flask-quart-themes 1.0.0
File Size Uploaded
flask-quart-themes-1.0.0.tar.gz 9.5 kB Details

Release files / flask-quart-themes-1.0.0.tar.gz

Download URL flask-quart-themes-1.0.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c077998bcb3d8784ce6ac9f6d619308608995105b2e3d400e550a85fd6efd478
BLAKE2b-256 checksum
How to use checksums
63955c71f864cb1fd3d18476343161d106ff8e744ed38a5fa835d63e0ad66cac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

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