Advanced

Advanced features for framework authors and power users

2 min read 375 words

Features for framework authors, SSG/SSR builders, and power users who need to go beyond standard template rendering.

Static Analysis
Analyze templates for dependencies, purity, and caching potential

Extract dependency paths, validate contexts, and plan caching strategies.

T-Strings (PEP 750)
Auto-escaping HTML and composable regex via Python 3.14 t-strings

Use thek() and r()tag functions for safe interpolation.

Compiler Internals
F-string coalescing, AST preservation, and render modes

Understand and tune the compilation pipeline.

Worker Auto-Tuning
Workload-aware parallelization for free-threaded Python

Optimal worker counts, template scheduling, and environment detection.

Security Hardening
Context-specific escaping, URL validation, and attribute safety

Protect against XSS in JavaScript, CSS, and URL contexts.

Profiling
Opt-in render instrumentation with zero overhead when disabled

Track block timings, macro calls, includes, and filter usage.

Block Caching
Connect analysis results to runtime block caching

Cache site-scoped blocks for 40-60% faster builds.

Scoped Slots
Pass data back from components to callers

Uselet:bindings on slots for data-driven component APIs.

Content Stacks
Collect content from nested templates

Use{% push %} and {% stack %}for deferred CSS, JS, and meta tags.

Sandbox
Restricted execution for untrusted templates

Limit attribute access, function calls, and imports.

CSP Nonces
Content Security Policy nonce injection

Auto-inject nonces into<script> and <style>tags.

Coverage
Measure template render coverage

Track which blocks, branches, and filters execute.

Type Checking
Static type analysis for template contexts

Catch missing variables and type mismatches before rendering.

Accessibility Linting
Check templates for accessibility issues

Detect missing alt text, form labels, and ARIA attributes.

Formatter
Auto-format template source code

Normalize indentation, whitespace, and tag style.