Sharing a mutable reference with Python

Background As part of my ongoing project to reimplement Django’s templating language in Rust, I have been adding support for custom template tags. Simple tags The simplest custom tag will look something like: # time_tags.py from datetime import datetime from django import template register = template.Library() @register.simple_tag def time(format_string): now = datetime.now() return now.strftime(format_string) # time_tags.py from datetime import datetime from django import template register = template.Library() @register.simple_tag def current_time(format_string): return datetime.now().strftime(format_string) ...

September 2, 2025

Quirks in Django's template language part 2

Django Rusty Templates Since September 2024, I have been building a reimplementation of Django’s templating language in Rust, called Django Rusty Templates. During this process, I have discovered several weird edge-cases and bugs, some of which I’ve talked about before. Centring strings Django supports a template filter for centring strings: {{ "Django"|center:10 }} which adds padding around the string to reach the provided length. In this simple case, the template is rendered as ··Django·· (where · represents a space character). ...

July 20, 2025