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.2.0.tar.gz
(92.2 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.2.0-py3-none-any.whl
(117.5 kB
view details)
File details
Details for the file palestine-0.2.0.tar.gz.
File metadata
- Download URL: palestine-0.2.0.tar.gz
- Upload date:
- Size: 92.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
800f378f55c99291fe147acb6f6a249df1e563696f6b05a526c33f7b5d86b0df
|
|
| MD5 |
5c6df355a648193bd8777164052a7262
|
|
| BLAKE2b-256 |
1fb2591c466eee69cf7269ee2711d93ab247f36422c58f8adaf069443ee20398
|
File details
Details for the file palestine-0.2.0-py3-none-any.whl.
File metadata
- Download URL: palestine-0.2.0-py3-none-any.whl
- Upload date:
- Size: 117.5 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 |
c223ffc549e77aa6fea089e4b5e0b2165547fd1cd1137210560e2a6c15228c38
|
|
| MD5 |
3c3ecf034e6d57c648c5778eafa866ce
|
|
| BLAKE2b-256 |
e7fa3e943bf1f2c03be9ce010f0380a1d457d07bab5e63e7d609b428426cff7b
|