fastpluggy-ui-tools

No description available

Official
v0.0.4
79 downloads this week
Latest version
Requires Python >=3.10

Quick Install

pip install fastpluggy-ui-tools
Or with specific version:
pip install fastpluggy-ui-tools==0.0.4

UI Tools Module for FastPluggy

A FastPluggy module that provides a collection of Jinja2 template filters and HTML rendering utilities for building user interfaces.
It includes base64 encoding, Pydantic model dumping, localization, JSON rendering, and image embedding.

Features

  • Base64 Encoding: b64encode filter to convert binary data to Base64 strings.
  • Pydantic Model Dump: pydantic_model_dump filter to serialize Pydantic BaseModel or BaseSettings instances to dictionaries.
  • Localization: localizedcurrency, localizeddate, and nl2br filters for number, date/time formatting, and newline-to-HTML conversions using Babel.
  • JSON Rendering: from_json filter and HTML list conversion utilities for safely displaying JSON data.
  • Image Rendering: Embed Base64-encoded images directly into templates with <img> tags.
  • Seamless Integration: Easy registration with FastPluggy via the UiToolsModule plugin.

Extra Widget

TODO: add widget description

Requirements

Install dependencies:

pip install -r requirements.txt

Usage

Template Filters

Filter Description
b64encode Base64-encode binary data (bytes → str).
pydantic_model_dump Dump Pydantic models/settings to dictionaries.
localizedcurrency Format a number as localized currency (default: EUR, fr_FR).
localizeddate Format dates/datetimes with various styles/locales/timezones.
nl2br Convert newline characters to <br> tags.
from_json Parse a JSON string into Python objects (list/dict).
render_bytes_size Format a size into human readable

Example in a Jinja2 template:

<h2>{{ user.name }}</h2>
<p>Balance: {{ user.balance | localizedcurrency('USD', 'en_US') }}</p>
<p>Joined: {{ user.joined_at | localizeddate('long', 'short', 'en_US') }}</p>
<pre>{{ config | pydantic_model_dump | pprint }}</pre>

HTML Rendering Utilities

Import and use functions from html_render.py to render JSON or image data in HTML:

from ui_tools.html_render import render_data_field, render_safe_data_field

# Render JSON string as HTML list
html_list = render_data_field(json_string)

# Safely render arbitrary data
safe_html = render_safe_data_field(raw_input)

Running Tests

Ensure you have pytest installed, then run:

pytest tests/

Contributing

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature.
  3. Commit your changes and push to your fork.
  4. Open a pull request for review.

License

This project is licensed under the MIT License. See LICENSE for details.

No Changelog Available

This plugin does not have a Changelog file or it could not be extracted from the package.

fastpluggy-ui-tools API

API documentation for this plugin is not available.

Package Analysis

Last analysis performed: 2025-07-06 19:26:43

✓ Valid Entry Point

This plugin has a valid entry point:
ui_tools = fastpluggy_plugin.ui_tools.plugin:UiToolsModule

Issues Found

Issues were found during analysis, but details are not available.

v0.0.5

v0.0.4

Latest

Plugin Information

Name
fastpluggy-ui-tools
Version
0.0.4
Entry Point
fastpluggy_plugin.ui_tools.plugin:UiToolsModule
Python
>=3.10
Status
✓ Official Plugin

Dependencies

babel
Comprehensive i18n and localization library for Python
Internationalization

Download Statistics

79
Weekly
338
Monthly
451
Total

Download Frequency: ~11 downloads per day
Average Per Day: 11.3 downloads
Last Download: 16 days ago
Yearly Estimate: 4115 downloads
28% estimated growth rate based on 40 days of data