All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Reimplementing Django Template Tags in Rust: Handling Context and Custom Tags

By

Bogdanp

9mo ago· 4 min readen

Summary

The article discusses the technical challenges of reimplementing Django's templating language in Rust, specifically focusing on handling custom template tags and the context object that behaves like a Python dictionary. It provides code examples for simple template tags and explains how Django's context contains a list of dictionaries to manage variable scope during template rendering.

Key quotes

· 4 pulled
Django's templating language uses an object called a context to provide dynamic data to the template renderer
This mostly behaves like a Python dictionary
Django's context contains a list of dictionaries
This allows for temporarily changing the value of a variable, for example within a {% for %} loop, while keeping the original value
Snippet from the RSS feed
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 date

You might also wanna read