Repository navigation
v0.3.0
The body of a bridged block tag now renders natively. Tags like {% localtime %}, {% timezone %}, {% cache %}, simple_block_tag, and third-party block tags call parser.parse(), which used to compile their body with Django's own parser, so everything inside ran at stock speed. Now the body compiles on the Rust parser.
pip install -U django-rust-templatesFaster
- Bridged block-tag bodies: wrapping a loop of aware dates in
{% localtime on %}used to render at 1.0x. It now renders 13.1x faster than stock, and asimple_block_tagaround a loop renders 14.5x faster. Compiling these templates went from 0.86x to 2–5x.
How it works
- The tag's own Python code still runs unchanged. Only its
parser.parse()call continues on the Rust parser. - The tag gets back a real
NodeList. Callingrender()renders the whole body natively. Inspecting it (get_nodes_by_type, iteration,len) sees stock-compatible nodes, and if a tag edits the list, it renders the edited list the stock way. {% block %}and{% partialdef %}inside a bridged tag keep working, including block overrides through{% extends %}.
Known gaps
{% blocktranslate %},{% static %}and humanizenaturaltimeare still Python.
Output stays byte-identical to stock Django. Django's template test suite passes 100% on 5.2 and 6.1.
Full change: #2