Palestine
A full spec DOM implementation in Python.
Installation
pip install palestine
Quick Start
from palestine import Document, Button, Div, Span
doc = Document()
body = doc.create_element('body')
doc.append_child(body)
btn = Button(type="submit", class_="primary")
btn.append_child(Text("Click me"))
body.append_child(btn)
print(doc)
# <!DOCTYPE html>
# <html><body><button type="submit" class="primary">Click me</button></body></html>
Features
Core DOM
- Nodes & Elements - Full DOM tree implementation with
Node,Element,Text,Comment, andDocument - HTML Parsing - Parse HTML strings into DOM trees with
parse_htmlandparse_fragment - Rendering - Render elements to HTML with
render_element,render_node, andminify
Components & Templating
- Template Engine - Create reusable templates with
Template - Component System - Build composable UI components with
Component,@component, andregister_component - Virtual DOM - Efficient updates with
VNode,h,render_vdom,diff_vdom, andpatch - Diffing - Compute and apply patches between DOM trees with
diffandapply_patches
Routing & State
- Router - Client-side routing with
Router,Route, andlink_element - Reactive Signals - Fine-grained reactivity with
Signal,Computed,Effect,computed,effect,batch - Store - Application state management with
Store,Action,create_store,combine_reducers
Styling & Animation
- Styled Elements - CSS-in-Python with
Styles,styled,Box,Flex,Grid - Animations - Keyframe animations and transitions with
Animation,Transition,animate - Built-in Animations - Pre-built effects like
fade_in,fade_out,slide_in,scale_in
Forms & Validation
- Form Builder - Declarative form construction with
FormBuilder - Validation - Schema validation with
Validator,Required,Email,URL,Pattern, and more - Serialization - JSON and form data serialization with
to_json,form_data,to_query_string
Web Standards
- Internationalization - i18n support with
I18n,create_i18n - SEO - Generate sitemaps, robots.txt, and structured data with
SEO - PWA - Service worker generation with
PWA,generate_service_worker - Feeds - RSS and Atom feed generation with
RSSFeed,AtomFeed - Sitemaps - XML sitemap generation with
Sitemap,SitemapIndex - Structured Data - Schema.org markup with
Schema - Open Graph & Twitter Cards - Social meta tags with
OpenGraph,TwitterCard
Security
- CSRF Protection - Token generation and validation
- HTML Sanitization - Safe HTML rendering with
sanitize_html,escape_html - Password Hashing - Secure password storage with
hash_password,verify_password - Rate Limiting - Request throttling with
RateLimiter - CSP Headers - Content Security Policy generation
Advanced Features
- Web Components - Custom elements with shadow DOM via
CustomElement,define_element - WebSocket - Real-time communication with
WebSocket,Channel - ORM - Database models with
Model,Field,QuerySet - Authentication - User auth with
Auth,login_user,logout_user,@login_required - File Uploads - Handle file uploads with
FileUpload,UploadedFile - Caching - LRU cache and memoization with
Cache,memoize,LRUCache - Charts - Data visualization with
Chart,BarChart,LineChart,PieChart - PDF Generation - Convert HTML to PDF with
PDF,html_to_pdf - Email - Email composition with
Email,EmailTemplate - GraphQL - GraphQL client with
GraphQLClient,query,mutation - Middleware - Request/response middleware with
MiddlewareStack
Developer Tools
- Testing - Test utilities with
TestCase,TestClient,TestResponse - Assertions - DOM assertions with
ElementAssert,DocumentAssert - Mock Server - API mocking with
MockServer,MockResponse - Debugging - Debug tools with
inspect,tree,stats,validate_html - Benchmarks - Performance testing with
Benchmark,benchmark_render - Pretty Print - Formatted HTML output with
pretty_print - Markdown - Markdown parsing with
markdown_to_html,Markdown - Export - Data export to CSV, TSV, JSON, XML, Excel with
to_csv,to_excel - Analytics - Analytics integration with
GoogleAnalytics,PlausibleAnalytics
WSGI Integration
from palestine import Document, html_response
def app(environ, start_response):
doc = Document()
# ... build your page
return html_response(doc, start_response)
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
palestine-0.1.0.tar.gz
(102.0 kB
view details)
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
palestine-0.1.0-py3-none-any.whl
(130.6 kB
view details)
File details
Details for the file palestine-0.1.0.tar.gz.
File metadata
- Download URL: palestine-0.1.0.tar.gz
- Upload date:
- Size: 102.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d67ed92de3193e2bd380214b4729e90e575001bdca216cb56af7f437c41ad82
|
|
| MD5 |
4e2bf2353dc1dee672956bf0f1e81f2b
|
|
| BLAKE2b-256 |
6e689ab32f04e51e1295091ede4702f08b8f73d9f312e6bda0fe3ce02245922a
|
File details
Details for the file palestine-0.1.0-py3-none-any.whl.
File metadata
- Download URL: palestine-0.1.0-py3-none-any.whl
- Upload date:
- Size: 130.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7a70671230c2d7a9cdb89256a8d44a58cd335e3db6732968f05d2a93086a240
|
|
| MD5 |
1b93909ec614ae86d5d796fcc47d8a81
|
|
| BLAKE2b-256 |
f4a22df591dfb7fcff58b8952fc119b160ce8a933b3e7eeb9a9a5056656f94c9
|