Class-based components for Flask
Project description
This module defines classes that can be rendered as "views" in a flask application.
The following example define a form to input some text as a component class (this additionally uses tailwindcss classes):
from flask_composed_views.components import BaseComponent, FormTextInput, Span, PlainText, FormSubmit
class WordInputForm(BaseComponent):
def __init__(self, id = None, classes = None, csrf_token: str | None = None):
form = Form(id='word-input-form',
classes=classes,
csrf_token=csrf_token,
action='/',
children=[
FormTextInput(label=Span(classes="p-2 font-bold",
children=PlainText('Word:', safe=True,)),
name='word',
id=id,
classes="border-1 border-solid broder-gray-400",
max_len=44),
FormSubmit(label=PlainText('Find'),
classes=" ".join([
"rounded-lg px-2 py-1 font-bold bg-yellow-200 hover:bg-yellow-300",
"active:bg-yellow-200 active:border-2 active:border-yellow-200",
"mx-4"
]))
])
super().__init__(id, classes, children=[form])
This form is rendered using:
csrf_token = ... # for example, using `flask_wtf.csrf.generate_csrf`
WordInputForm(csrf_token=csrf_token).render()
which could theoretically be used as the output of an @app.route-decorated function. Normally you would embed it within a page layout, etc.
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 flask_composed_views-0.0.0.tar.gz.
File metadata
- Download URL: flask_composed_views-0.0.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ceba6c95b12f0004f09f40dc2c2aa3afdf8bd92d47637ffa848614949c23025
|
|
| MD5 |
129c322ca4b4cd14a494ddc4f1cb081e
|
|
| BLAKE2b-256 |
6b61e4e1ca6febb60fcf5bca3c2025ba415624678957657e402288b8abf01c3d
|
File details
Details for the file flask_composed_views-0.0.0-py3-none-any.whl.
File metadata
- Download URL: flask_composed_views-0.0.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3551d580fab2eba615b11e67c7e192e7ff1604debbc987960afa1bce7a3ef23f
|
|
| MD5 |
3d17942398fa16e5738b4b69996451ca
|
|
| BLAKE2b-256 |
240b9a241a277e16dc121c2dfe316082d3522e5a9dc98eb5dc8c8fdb6afa95f6
|